...

View Full Version : HTML email???



fireblade
06-12-2007, 10:53 AM
in PHP normal mail function

mail($to, $subject, $body)
can I use HTML body which contains
<a href="link">some text </a>codes like.......

will the mail be sent as HTML??

if not what should i do to send HTML mail??? any body can help me??

_Aerospace_Eng_
06-12-2007, 10:59 AM
The mail() function accepts 4 items. The to email address, the subject, the message, and the headers. If you don't specify the headers the default is text/plain. Put this before you call the mail() function

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: you@domain.com\r\n" .
"Reply-To: ".$to."";
Then you call the mail() function like so

mail($to, $subject, $body,$headers)

meth
06-12-2007, 03:59 PM
Another tip for html email, use heredoc syntax (http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc) to build the html of the message. Heredoc behaves like double quotes without having to actually use them. Very handy for html tags with lots of attributes...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum