为什么Outlook 2010会破坏我的HTML电子邮件正文?

时间:2014-10-22 03:01:28

标签: html email outlook smtp mime

每当我从我自己的服务器(使用我自己的电子邮件代码)向Outlook 2010发送HTML电子邮件时,它会删除每个HTML属性的前2个字符。

这是HTML正文的一个片段(请参阅表格属性搞砸了):

<table cellpadding=" cellspacing=" border=" class=ostdata">  
<thead>                               
<tr>                                       
<th>Field</th>                                 
<th>Value</th>                               
</tr>     
</thead>
<tr>                
<th>Test</th>  
<td>Hello world!</td>
</tr>
</table>

Outlook 2010中的完整HTML正文:

<style> BODY     {font-family:Arial,Helvetica,Tahoma,sans-serif;font-size:12px;font-weight:normal;color:#4F4F4F;margin:8px;padding:0}      H1                           {font-size:14px;font-weight:bold;margin-top:18px} .postdata                                                                                             {margin:10px;padding:10px 0} .postdata TABLE                                  {font-family:Arial,Helvetica,Tahoma,sans-serif;font-size:12px;font-weight:normal;color:#4F4F4F}            .postdata TH                                                           {font-weight:bold;color:#FFF;text-align:left;padding:4px 8px;background-color:#555}                .postdata TD                                                      {padding:4px 8px}           .postdata THEAD TH        {font-size:0.85em;font-weight:normal;text-transform:uppercase;background-color:#444} .signature                                                                     {color:#9F9F9F;margin:40px 0 10px 0}</style>Test email with single <table style=olor: red" width=00%"><tr><td>Table data</td></tr></table><table cellpadding=" cellspacing=" border=" class=ostdata">  <thead>                               <tr>                                       <th>Field</th>                                 <th>Value</th>                               </tr>     </thead><tr>                <th>Test</th>  <td>Hello world!</td></tr></table>

Outlook 2010中的标题(我无法在Outlook 2010中查看整个源代码):

Return-Path: <REMOVED>
Delivered-To: REMOVED
Received: (qmail 31757 invoked by alias); 22 Oct 2014 02:50:45 -0000
Delivered-To: alias-localdelivery-REMOVED
Received: (qmail 31751 invoked by uid 102); 22 Oct 2014 02:50:45 -0000
Date: 22 Oct 2014 02:50:45 -0000
Message-ID: <20141022025045.31750.REMOVED>
To: REMOVED
Subject:
From: REMOVED
X-Mailer: MailBot version 1.24
MIME-Version: 1.0
Content-Type: multipart/alternative;
                boundary="MailBot=="

使用Mac Mail 7.3打开完整的HTML电子邮件:

Return-Path: <REMOVED>
Delivered-To: REMOVED
Received: (qmail 32582 invoked by alias); 22 Oct 2014 02:57:39 -0000
Delivered-To: alias-localdelivery-REMOVED
Received: (qmail 32579 invoked by uid 102); 22 Oct 2014 02:57:39 -0000
Date: 22 Oct 2014 02:57:39 -0000
Message-ID: <20141022025739.32578.REMOVED>
To: REMOVED
Subject: 
From: REMOVED
X-Mailer: MailBot version 1.24
MIME-Version: 1.0
Content-Type: multipart/alternative;
    boundary="MailBot=="

This is a multipart message in MIME format.

--MailBot==
Content-Type: text/plain;
    charset="us-ascii"
Content-Transfer-Encoding: 7bit

Test email with single

--MailBot==
Content-Type: text/html;
    charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<style> BODY    {font-family:Arial,Helvetica,Tahoma,sans-serif;font-size:12px;font-weight:normal;color:#4F4F4F;margin:8px;padding:0}    H1      {font-size:14px;font-weight:bold;margin-top:18px} .postdata                     {margin:10px;padding:10px 0} .postdata TABLE            {font-family:Arial,Helvetica,Tahoma,sans-serif;font-size:12px;font-weight:normal;color:#4F4F4F} .postdata TH                {font-weight:bold;color:#FFF;text-align:left;padding:4px 8px;background-color:#555} .postdata TD                {padding:4px 8px}   .postdata THEAD TH  {font-size:0.85em;font-weight:normal;text-transform:uppercase;background-color:#444} .signature                 {color:#9F9F9F;margin:40px 0 10px 0}</style>Test email with single <table style="color: red" width="100%"><tr><td>Table data</td></tr></table><table cellpadding="0" cellspacing="1" border="0" class="postdata">   <thead>     <tr>            <th>Field</th>          <th>Value</th>      </tr>   </thead><tr>    <th>Test</th>   <td>Hello world!</td></tr></table>

--MailBot==--

为什么Outlook会这样做?

1 个答案:

答案 0 :(得分:2)

症状与声明Content-Transfer-Encoding: quoted-printable一致,但实际上并没有使用此编码,而且您发布的标题似乎证实了这一点。

在QP中,您会有attribute=3D"value",因为等号是此编码中的元字符,需要编码为=3D。它是可以理解的(尽管可能不完全正确),一个等号后跟两个非十六进制(和非换行)字符的序列被Outlook丢弃为非法。

无论如何,我会责怪你发送的代码 - 你没有展示 - 而不是Outlook(即使我个人认为Outlook应该因其他原因而被禁止)。