hamp13 hamp13 - 1 month ago 6x
PHP Question

Why isn't the html of sent mails being rendered?

My script send the email but it doesn't render the html tags. I'm not sure why not.

$email = $row['email'];

$mail_body = '<html>

<p>this is a testing email </p>
<hr />
<p>by server</p>
$subject = "Better website";
$to = "$email";

$headers = "From: mailscript@hotmail.com\r\n";
$headers .= "Content-Type: text/html\r\n";

$mail_result = mail($to, $subject, $mail_body, $headers);


Try setting the mime type as well as shown in the manual for mail()

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