php mail headers for outlook - the email arrives empty to outlook, and great to gmail to yahoo

sdfor picture sdfor · Aug 18, 2009 · Viewed 8k times · Source
mail($to, $subject, $message, $headers);

the $header is:

From: [email protected]
Reply-To: [email protected]
Content-Type: text/html; charset=iso-8859-1
X-Mailer: PHP/5.2.5
MIME-Version: 1.0

I built $header with those line and I changed the order in every way, putting the Mime in the beginning, at the end, moving the from and reply around adding and deleting the X-mailer line. The results are the same. Gmail and yahoo are fine and the email is an empty attachment when set to outlook 2003.

Any thoughts?

sdfor

Answer

sdfor picture sdfor · Aug 19, 2009

thanks for the thoughts. I tried phpMailer and got stuck on a "Could not instantiate mail function" error. I posted a question about that too.

But I figured out the problem. Outlook requires a doctype and that the HTML be correct. gmail will take almost anything. \

The following works!

//the message:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head></head>
<body>
<h1>HTML EMAIL</h1>
</body>
</html>

//the headers

$headers = "From: $from\n"
$headers .= "Reply-To: $replyto\n"
$header .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";

// the mail call

mail($to, $subject, $message, $headers);