Forum Moderators: coopster

Message Too Old, No Replies

MIME-Version email header messes up Outlook (WebMail)?!

Using PHP mail() to send MIME encoded emails.

         

penders

10:48 am on Sep 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I've been sending mime encoded emails (text/plain with alternative text/html and a base64 encoded attachment) using the standard PHP mail() [uk.php.net] function.

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

Googlemail and Hotmail displayed these emails OK. However, Outlook (WebMail) was displaying the entire email as text/plain - you could see all the mime encoding 'Content-Type's and base64 encoded jumble! (Other mime-encoded emails displayed OK.)

(Unfortunately I'm unable to check Outlook 'proper' at the current time.)

After much messing I've found that the "MIME-Version: 1.0" header was causing the problem! If this occurs anywhere but the very last item in the list of $headers then the entire email appears as text/plain in Outlook (WebMail)!

If this is a quirk of Outlook (WebMail) then may be this will help someone with a similar problem (as I couldn't find any mention of this particular issue elsewhere)?! Others seem to have had the problem of receiving mime encoded emails as plain text in Outlook, but either the reasons given have been different or the issue has gone unresolved.

However, I'm rather puzzled as I've seen nothing on the net to suggest that the "MIME-Version" header can cause problems (other than when a different version number is specified). I'm under the impression that the "MIME-Version" header is rather important(!) and in many examples (including on the PHP mail() manual page) occurs as the first item in the list of headers when sending a mime encoded email.

Has anyone else experienced this? Am I missing something?

(It seems most email clients will receive a mime-encoded email OK even without the MIME-Version header?!)

eelixduppy

5:50 am on Sep 15, 2008 (gmt 0)



Have you found your solution to this yet? Anything more to share about the issue?

penders

12:29 pm on Sep 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Well, it does work OK, providing you're careful where you put the MIME-Version header (in the $headers variable when passed to the mail() function). It needs to be last for Outlook to behave. (Have now tested that this works OK on Outlook 2003 - not just Outlook WebMail)

For instance, this works OK:

From: "Example Portal" <noreply@example.com> 
Reply-To: me@example.com
Content-Type: multipart/mixed; boundary="----=_Part_ABC7392736_1"
X-Mailer: PHP/5.2.5
MIME-Version: 1.0

However, this does not (Outlook suddenly sees the email as plain text!):

MIME-Version: 1.0 
From: "Example Portal" <noreply@example.com>
Reply-To: me@example.com
Content-Type: multipart/mixed; boundary="----=_Part_ABC7392736_1"
X-Mailer: PHP/5.2.5

In the beginning, I had the MIME-Version header just before the Content-Type header, but this did not work either.

The $headers are separated by "\r\n". (Lines in the $body are separated by "\n" - I assume that would be the norm?)

Alternatively, just remove the MIME-Version header altogether!

Other than that I have got no further in understanding this. It works, but I don't know why the MIME-Version header should apparently cause Outlook such grief?