带有html内容的电子邮件功能

i am trying to send e-mail with html code inside. i have following code;

$message ="<html><head><title></title></head><body>test</body></html>"; 
$rmail = $mail_email;
$subject = "subject";
$head = "MIME-Version: 1.0 ";
$head .= "Content-type: text/html; charset=utf8";           
$head .= "Date: ".date("r")." ";
$mail_at=mail($rmail, $subject, $message, $head);

but, when i open the mail, mail content is,

<html><head><title></title></head><body>test</body></html>

it is just sending the string not compile the html code.

You need to add newlines in your header

 $head = "MIME-Version: 1.0 
";
 $head .= "Content-type: text/html; charset=utf8 
";           
 $head .= "Date: ".date("r")." 
";

Otherwise the Content-type header is on the same line as MIME-versionwhich won't work

Mostly works for me but I've seen some servers where it only works with