views:

32

answers:

1

Hi,

I know this is simple but my brain is fried from trying to solve a different problem!

I'm using php's mail function to email the user. Below is my code. See the a href link, how do I get this to display as an actual link within the php?

[email protected];
$content= "Dear Whoever,    
NB: Please click <a href=\"document.pdf\" target=\"_blank\">here</a> to read and download the terms and conditions.";

mail( "$email", "Welcome", $content, "From: [email protected]"); 
+1  A: 

As noted above, your code has error. It should be:

email='[email protected]';
$content= "Dear Whoever,    
NB: Please click <a href=\"document.pdf\" target=\"_blank\">here</a> to read and download the terms and conditions.";

mail( $email, "Welcome", $content, "From: [email protected]"); 

You would need to set the mime type to HTML in the header, and use it as a parameter in the mail() function.

From the manual

// 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";

// Additional headers
$headers .= 'To: Mary <[email protected]>, Kelly <[email protected]>' . "\r\n";
$headers .= 'From: Birthday Reminder <[email protected]>' . "\r\n";
$headers .= 'Cc: [email protected]' . "\r\n";
$headers .= 'Bcc: [email protected]' . "\r\n";

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

Though I usually use SwiftMailer and it has other neat features.

Extrakun
Thanks @Extrakun
TaraWalsh
Sending HTML email without a plain text alternative is a good way to ramp up your spam score. Always use multipart MIME email if you want to include an HTML version.
David Dorward