Outlook Express is not recognizing *some* HTML emails

戏子无情 提交于 2021-02-19 07:38:28

问题


I'm using HTML emails for a client's newsletter. Not using HTML mails is not an option. I've used PHPMailer for mailing, but I've also tried using PHP's mail() function directly. In both instances, I get the same problem described below. I've tried sending as multipart as well as sending just the HTML version.

In every email client I tried, the emails arrive just fine. By that I mean the email is recognized as an HTML email and the content is rendered. Except on some accounts on Outlook Express. I've not been able to discern why it works for some people and why it doesn't work for others (all using Outlook Express). I have forwarded HTML emails to this account (from gmail as well as from outlook express) and they show up just fine. So the Outlook Express version is definitely capable of showing HTML emails.

Now, in these failing cases, the Outlook Express ignores a significant part of the mail header. I can actually see this: when I view the original source of the email, it shows a part in bold - the header - and a part not in bold - the body.

Below is the email message. I've redacted some "personal" parts.

This part is in bold, recognized by Outlook Express as the header:

DomainKey-Status: no signature
Received: (qmail xxxx invoked by uid xxx); 22 Dec 2008 21:04:33 +0100
To: xxxxxxxxxxxxxxxxxx
Subject: Test
Date: Mon, 22 Dec 2008 21:04:33 +0100

And this part is not in bold, and shows up in the mail content panel of Outlook Express.

From: Root User <xxxxxxxxxxxxxxxxxxxxxx>
Message-ID: <xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
X-Priority: 3
X-Mailer: PHPMailer (phpmailer.sourceforge.net) [version 2.0.3]
MIME-Version: 1.0
Content-Type: multipart/alternative;
    boundary="b1_cb79043f473b53e87bfa759755fce3ce"

--b1_cb79043f473b53e87bfa759755fce3ce
Content-Type: text/plain; charset = "iso-8859-1"
Content-Transfer-Encoding: 8bit
test

--b1_cb79043f473b53e87bfa759755fce3ce
Content-Type: text/html; charset = "iso-8859-1"
Content-Transfer-Encoding: 8bit
<p>Test</p>

--b1_cb79043f473b53e87bfa759755fce3ce--

回答1:


Okay, I think I solved the problem. The various lines in the header were separated by \r\n and apparently Outlook expected them to be separated by \n only. Even PHPMailer seems to do this, so I'm using PHP's mail() function now.




回答2:


Adding a newline before the HTML in the second MIME block will fix your issue. You can also set "Content-Disposition: inline" on that block, if you want. In my tests, I still had to hit Alt+Shift+H in Outlook Express, as it defaults to plain text for security reasons.

Here is the final working EML:

DomainKey-Status: no signature
Received: (qmail xxxx invoked by uid xxx); 22 Dec 2008 21:04:33 +0100
To: xxxxxxxxxxxxxxxxxx
Subject: Test
Date: Mon, 22 Dec 2008 21:04:33 +0100
From: Root User <xxxxxxxxxxxxxxxxxxxxxx>
Message-ID: <xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
X-Priority: 3
X-Mailer: PHPMailer (phpmailer.sourceforge.net) [version 2.0.3]
MIME-Version: 1.0
Content-Type: multipart/alternative;
    boundary="b1_cb79043f473b53e87bfa759755fce3ce"

--b1_cb79043f473b53e87bfa759755fce3ce
Content-Type: text/plain; charset = "iso-8859-1"
Content-Transfer-Encoding: 8bit
test

--b1_cb79043f473b53e87bfa759755fce3ce
Content-Type: text/html; charset = "iso-8859-1"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline

<p>Test</p>

--b1_cb79043f473b53e87bfa759755fce3ce-- 



回答3:


I found that if this problem is when I use PHPMailer v 2.3. When I upgraded to PHPMailer_v5.0.2 mails are correctly showed in outlook.




回答4:


Try to change creating of boundaryies:

/* Set the boundaries */
$uniq_id = md5(uniqid(time()));

$this->boundary[1] = '------------01' . $uniq_id; // was started by b1_

$this->boundary[2] = '------------02' . $uniq_id; // was started by b2_

Tomor.cz

Edit: Thats not the solution: :/

But I found that, if i use phpmailer via smtp server it's ok and when I send email via mail() function it's problem in outlook then..



来源:https://stackoverflow.com/questions/387229/outlook-express-is-not-recognizing-some-html-emails

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!