Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Outlook将HTML显示为文本_Html_Ruby On Rails_Email_Outlook - Fatal编程技术网

Outlook将HTML显示为文本

Outlook将HTML显示为文本,html,ruby-on-rails,email,outlook,Html,Ruby On Rails,Email,Outlook,我从ruby on rails应用程序发送电子邮件。所有电子邮件客户端都会显示我的电子邮件gmail、bat、thunderbird等,但不会显示Outlook: 在outlook中,我看到以下内容: my message text --mimepart_4e514d8786c25_d59..fdab8042069c Content-Type: multipart/related; charset=f-8 Content-Transfer-Encoding: Quoted-printable

我从ruby on rails应用程序发送电子邮件。所有电子邮件客户端都会显示我的电子邮件gmail、bat、thunderbird等,但不会显示Outlook:

在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模式下都显示良好:


您是如何构建此邮件的?您是否手动添加标题

我不知道charset=f-8是从哪里来的,但这是一个bug,它使得包含Content Type:text/html部分的整个标题行无效。你很幸运,其他邮件客户不想在那里太严格

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


如果您没有手动添加这些邮件头,而ActionMailer反而变得厚颜无耻,请在构建邮件的地方发布一些代码。可能值得再问一个问题。

您是如何构建此邮件的?您是否手动添加标题

我不知道charset=f-8是从哪里来的,但这是一个bug,它使得包含Content Type:text/html部分的整个标题行无效。你很幸运,其他邮件客户不想在那里太严格

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


如果您没有手动添加这些邮件头,而ActionMailer反而变得厚颜无耻,请在构建邮件的地方发布一些代码。可能值得发布另一个问题。

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某些Outlook版本在内容处置时不会直接显示HTML消息:内联标题被明确设置为文本/HTML部分。

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某些Outlook版本在内容处置:内联标题明确设置为文本/HTML部分时,不会直接显示HTML消息。

顶部的空多部分/相关选项有什么意义?我认为发送multipart/*类型的一部分而不为其定义一个内部分隔符并给它一个终止行是不合法的。IANA字符集注册表也不知道charset=f-8。上面的空multipart/相关替代项有什么意义?我认为发送multipart/*类型的一部分而不定义内部分隔符并给它一个终止行是不合法的。IANA字符集注册表也不知道charset=f-8。