After beating my head against this similar problem for a while today, and googling it to death without success, I believe I have come up with a proper fix for it (not to take away from your fix, gjr, as it gave me sufficient inspiration to dig deeper).
Symptom:
HTML messages generated in PHP render fine in Thunderbird, Mac Mail and Squirrelmail but do
not render properly in Outlook, Outlook Express, or Outlook Web Access.
Investigation:
Testing was done with a single IMAP mail account - accessing it using multiple email clients. This ensured that the only variable in the equation was the email client. As gjr pointed out, the issue appears to be that the MS products are dropping certain characters. In particular, any equals sign followed by a quote and another character has the quote and character dropped (ie: <a href=
"blah"> becomes <a href=lah">).
Solution:
Changing the message encoding type from "quoted-printable" to "base64" and tossing the HTML message through a chunk_split(base64_encode()) allows the html email to render properly in all tested mail readers.
Thanks to
Leon Atkinson at Zend:
http://www.zend.com/zend/trick/html-...1&anc=0&view=1
(quote: "I used base64 encoding instead of quoted-printable because Microsoft's e-mail clients appear to have trouble with quoted-printable messages.")
Before:
PHP Code:
if ($email_body['html']) {
$email_body['html'] = "--".$alternative_mime_boundary.$s_eol.
"Content-Type: text/html; charset=\"iso-8859-1\"; format=flowed" .$s_eol.
"Content-Transfer-Encoding: quoted-printable".$s_eol.$s_eol.
$email_body['html'].$s_eol.$s_eol.
"--".$alternative_mime_boundary."--".$s_eol.$s_eol;
}
After:
PHP Code:
if ($email_body['html']) {
$email_body['html'] = "--".$alternative_mime_boundary.$s_eol.
"Content-Type: text/html; charset=\"iso-8859-1\";" .$s_eol.
"Content-Transfer-Encoding: base64".$s_eol.$s_eol.
chunk_split(base64_encode($email_body['html'])).$s_eol.$s_eol.
"--".$alternative_mime_boundary."--".$s_eol.$s_eol;
}
Possible Cause:
Your guess is as good as mine - probably related to =" being a "keyword" of sorts for some mime functionality.
Possible Side Effects:
I suppose on a
very heavily loaded web server you would see performance degredation from the extra chunk_split and base64_encode calls. Can't see it really being an issue, though.
Hope this helps somebody else when they're googling for this.
(my search terms were "outlook html rendering problem dropped characters -vulnerability" and it didn't get my anywhere - I'm mentioning it here to help future googlers with their search for this problem/solution)
Aaron