sending HTML email with a variable in the URL

Posted by Rob Crouch on Stack Overflow See other posts from Stack Overflow or by Rob Crouch
Published on 2012-11-19T22:40:54Z Indexed on 2012/11/19 23:00 UTC
Read the original article Hit count: 326

Filed under:
|
|
|

I am using the following script to send a dynamic page (php) as a html email... the page being emailed uses a variable in the URL to determine what record is shown from a database

<?

 $evid = $_GET['evid'];

    $to  = '[email protected]';
$subject = 'A test email!';

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Put your HTML here
$message = file_get_contents('http://www.url.co.uk/diary/i.php?evid=2');

// Mail it
mail($to, $subject, $message, $headers);

?>

as you can see the html file being emailed has a evid variable... if i set this to $evid and try to send the variable when running the current script I get an error... does anyone know of a way round this?

hope i explained that clear enough Rob

© Stack Overflow or respective owner

Related posts about php

Related posts about html