Outlook将HTML显示为TEXT

时间:2011-08-21 18:35:05

标签: html ruby-on-rails email outlook

我在rails app上发送来自我的ruby的电子邮件。所有电子邮件客户端都显示我的电子邮件(gmail,蝙蝠,雷鸟等),但不显示Outlook :(

在展望中我看到了:

my message text

--mimepart_4e514d8786c25_d59..fdab8042069c
Content-Type: multipart/related; charset=f-8
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline

--mimepart_4e514d8786c25_d59..fdab8042069c
Content-Type: text/plain; charset=f-8
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline

my email text message

--mimepart_4e514d8786c25_d59..fdab8042069c
Content-Type: text/html; charset=f-8
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline

my email html code (<h1>test</h1><table...)

--mimepart_4e514d8786c25_d59..fdab8042069c--

怎么了?

以前来自outlook的标题:

Message-Id: <4e514d88.100fdf0a.403c.31a7@mx.xxx.ccc>
Subject: =?utf-8?Q?=D0=97=D0=B0=D0=BF=D1=80=D0=BE=D1=81_=D0=B4=D0=BB=D1=8F_=D0=BC=D0=B5=D0=BD=D0=B5=D0=B4=D0=B6=D0=B5=D1=80=D0=B0_=D0=BA=D0=BE=D0=BC=D0=BF=D0=B0=D0=BD=D0=B8=D0=B8_?=
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=mimepart_4e514d8786c25_d59..fdab8042069c
User-Agent: Rails Application
X-Mailer: Rails Mailer
Return-Path: admin@xxx.ccc
X-Yandex-Forward: 8a20ef6ffc7eeb7ef7c8d000508718e0

来自gmail的同一封电子邮件,其中所有内容均显示为文字和html模式:

Delive
Message-Id: <4e514d88.100fdf0a.403c.31a7@mx.xxx.com>
Subject: xxx
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=mimepart_4e514d8786c25_d59..fdab8042069c
User-Agent: Rails Application
X-Mailer: Rails Mailer
X-Yandex-Forward: 8a20ef6ffc7eeb7ef7c8d000508718e0


--mimepart_4e514d8786c25_d59..fdab8042069c
Content-Type: multipart/alternative; charset=utf-8
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline

email text 


--mimepart_4e514d8786c25_d59..fdab8042069c
Content-Type: multipart/related; charset=utf-8
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline


--mimepart_4e514d8786c25_d59..fdab8042069c
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline

email text (plain text)

--mimepart_4e514d8786c25_d59..fdab8042069c
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline


email text(html)

--mimepart_4e514d8786c25_d59..fdab8042069c--

2 个答案:

答案 0 :(得分:3)

你是如何构建这封邮件的?您是否手动添加了标题?

我不知道哪里 charset = f-8 来自哪里,但它是一个错误,它呈现整个标题行包含Content-Type: text/html部分无效。你很幸运,其他邮件客户并不觉得那里非常严格。

无效的标题行导致Outlook将该部分解释为纯文本,这是相当明智的。

如果您没有手动添加这些标题,而且ActionMailer会更加厚颜无耻,请发布一些构建邮件的代码。可能值得发布另一个问题。

答案 1 :(得分:1)

(1)样本中的多部分结构是错误的;你需要实现这样的层次结构(使用适当的传输编码和其他细节):

Content-Type: multipart/alternative; boundary="LEVEL0"

--LEVEL0
Content-Type: text/plain; ...
email text...

--LEVEL0
Content-Type: multipart/related; boundary="LEVEL1"

--LEVEL1
Content-Type: text/html; ...
<html><body>...

--LEVEL1
Content-Type: image/jpeg; ...
...

--LEVEL1--

--LEVEL0--

(2)当Content-Disposition:内联标题明确设置为“text / html”部分时,某些Outlook版本不会直接显示HTML消息。