php mail headers for outlook - the email arrives empty to outlook, and great to gmail to yahoo
-
18-09-2019 - |
Question
mail($to, $subject, $message, $headers);
the $header is:
From: from-me@mymail123.com Reply-To: from-me@mymail123.com 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
Solution
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);
OTHER TIPS
Personnally, i prefer using phpmailer, available on sourceforge. It offers a much more robust mailing solution. I use it to send our email newsletter. Very reliable.
Try adding to the end of 'From: ...'. This email should be an actual email address on the server. Try checking your spam folder with what you have.