0

我正在创建一个发送包含大量嵌入图像的电子邮件的服务。并且这些图像通常会在使用 Chrome 和其他浏览器的 gmail 网络客户端中随机丢失(参见随附的屏幕截图)。我确定图像发送正确。图像附加到电子邮件中,丢失的图像可以使用 Chrome 上下文菜单成功下载。如果我按 ctrl+F5 将显示图像(或其他图像消失)。此外,这些电子邮件在 Thunderbird 或 MS Outlook 中也能正常显示。

这是我的 Chrome 的截图:

在此处输入图像描述

请建议我如何更改电子邮件正文(可能添加一些标题等)以解决此问题!

不推荐使用外部图像(如<img src="http://mydomain/img.png">)。只有嵌入的图像,如<img src="cid:img.png">

这些电子邮件是通过 Amazon Web Services 邮件发件人发送的。另外我正在使用 javamail 发送图像。

这是一个示例电子邮件文本:

Return-Path: <0000014117bed1a2-aad7fbff-afdd-43ea-a658-825a817e9903-000000@amazonses.com>
Received: from a8-83.smtp-out.amazonses.com (a8-83.smtp-out.amazonses.com. [54.240.8.83])
        by mx.google.com with ESMTP id nd18si8517742qeb.113.1969.12.31.16.00.00;
        Fri, 13 Sep 2013 08:36:38 -0700 (PDT)
Received-SPF: pass (google.com: domain of 0000014117bed1a2-aad7fbff-afdd-43ea-a658-825a817e9903-000000@amazonses.com designates 54.240.8.83 as permitted sender) client-ip=54.240.8.83;
Authentication-Results: mx.google.com;
       spf=pass (google.com: domain of 0000014117bed1a2-aad7fbff-afdd-43ea-a658-825a817e9903-000000@amazonses.com designates 54.240.8.83 as permitted sender) smtp.mail=0000014117bed1a2-aad7fbff-afdd-43ea-a658-825a817e9903-000000@amazonses.com
Return-Path: 0000014117bed1a2-aad7fbff-afdd-43ea-a658-825a817e9903-000000@amazonses.com
From: <my service email here>
Sender: <my service email here>
To: <my receiver email here>
Message-ID: <0000014117bed1a2-aad7fbff-afdd-43ea-a658-825a817e9903-000000@email.amazonses.com>
Subject: =?UTF-8?Q?RedHelper_-_=D0=BF?=
 =?UTF-8?Q?=D0=BB=D0=B0=D0=BD=D0=BE=D0=B2=D1=8B=D0=B9?=
 =?UTF-8?Q?_=D0=BE=D1=82=D1=87=D1=91=D1=82_?=
 =?UTF-8?Q?(c_06.09.2013_=D0=BF=D0=BE_12.09.2013)?=
MIME-Version: 1.0
Content-Type: multipart/related; 
    boundary="----=_Part_0_68348157.1379082638282"
Date: Fri, 13 Sep 2013 14:34:43 +0000
X-SES-Outgoing: 2013.09.13-54.240.8.83

------=_Part_0_68348157.1379082638282
Content-Type: text/html;charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Cache-Control: no-cache, no-store, must-revalidate
Pragma: no-cache
Expires: 0

<table width=3D"750" align=3D"center" bgcolor=3D"#f2f4e6" cellpadding=3D"0"=
 cellspacing=3D"0"
=09   style=3D"
=09   =09=09border-collapse: collapse;
=09   =09=09font-family: arial, sans-serif;
=09   =09=09color: #374550;
=09   =09=09font-size: 14px;
=09   =09=09">
=09<tr>
=09=09<td>
=09=09=09<img src=3D"cid:client_report_header.png" alt=3D"RedHelper - =D0=
=BF=D0=BB=D0=B0=D0=BD=D0=BE=D0=B2=D1=8B=D0=B9 =D0=BE=D1=82=D1=87=D1=91=D1=
=82" width=3D"750" height=3D"124"/>

...........................
The rest of email body
...........................

------=_Part_0_68348157.1379082638282
Content-Type: image/png; name=client_report_header.png
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename=client_report_header.png
Content-ID: <client_report_header.png>
X-Attachment-Id: client_report_header.png

...........................
base64 encoded image
...........................
...........................
then a lot of other images
...........................

请帮我解决这个问题,我陷入了僵局:(

更新:

我探索了浏览器对嵌入图像的请求,发现 gmail 附件服务有时会返回错误的响应标头(例如,使用 text/html 类型插入图像/png),然后图像不会显示。

这是一个“好”响应标头的示例(从 Chrome 开发人员工具中复制):

Request URL:https://mail-attachment.googleusercontent.com/attachment/u/0/?ui=2&ik=da16498049&view=att&th=141543ec8afd95ce&attid=0.49&disp=emb&zw&atsh=1&saduie=AG9B_P_B99tk3pnLfQHlDF_gPQKM&sadet=1380097953720&sads=D0OzbnmhqzBZ6htOe0o3RTWuwvw
Request Method:GET
Status Code:200 OK

Request Headers
:host:mail-attachment.googleusercontent.com
:method:GET
:path:/attachment/u/0/?ui=2&ik=da16498049&view=att&th=141543ec8afd95ce&attid=0.49&disp=emb&zw&atsh=1&saduie=AG9B_P_B99tk3pnLfQHlDF_gPQKM&sadet=1380097953720&sads=D0OzbnmhqzBZ6htOe0o3RTWuwvw
:scheme:https
:version:HTTP/1.1
accept:image/webp,*/*;q=0.8
accept-encoding:gzip,deflate,sdch
accept-language:en-US,en;q=0.8,ru;q=0.6
cookie:S=gmail=QQ8uQOaAEhQ4x5TFVYcQhg
referer:https://mail.google.com/mail/u/0/
user-agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.76 Safari/537.36
x-chrome-variations:CK61yQEIhrbJAQiqtskBCMS2yQEIt4XKAQjxhsoB

Response Headers
access-control-allow-credentials:true
alternate-protocol:443:quic
cache-control:private, max-age=86400
content-disposition:attachment; filename="visitors_capture_pic.png"
content-length:4336
content-type:image/png
date:Wed, 25 Sep 2013 08:32:14 GMT
server:GSE
status:200 OK
version:HTTP/1.1
x-content-type-options:nosniff
x-xss-protection:0

这是“坏”响应标头的示例:

Request URL:https://mail-attachment.googleusercontent.com/attachment/u/0/?ui=2&ik=da16498049&view=att&th=141543ec8afd95ce&attid=0.5&disp=emb&zw&atsh=1&saduie=AG9B_P_B99tk3pnLfQHlDF_gPQKM&sadet=1380097948083&sads=37LZqateabeXb45jYSk9ooGybwI
Request Method:GET
Status Code:200 OK

Request Headers
:host:mail-attachment.googleusercontent.com
:method:GET
:path:/attachment/u/0/?ui=2&ik=da16498049&view=att&th=141543ec8afd95ce&attid=0.5&disp=emb&zw&atsh=1&saduie=AG9B_P_B99tk3pnLfQHlDF_gPQKM&sadet=1380097948083&sads=37LZqateabeXb45jYSk9ooGybwI
:scheme:https
:version:HTTP/1.1
accept:image/webp,*/*;q=0.8
accept-encoding:gzip,deflate,sdch
accept-language:en-US,en;q=0.8,ru;q=0.6
cookie:S=gmail=QQ8uQOaAEhQ4x5TFVYcQhg
referer:https://mail.google.com/mail/u/0/
user-agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.76 Safari/537.36
x-chrome-variations:CK61yQEIhrbJAQiqtskBCMS2yQEIt4XKAQjxhsoB

Response Headers
alternate-protocol:443:quic
cache-control:no-cache, no-store, max-age=0, must-revalidate
content-encoding:gzip
content-type:text/html; charset=UTF-8
date:Wed, 25 Sep 2013 08:32:09 GMT
expires:Fri, 01 Jan 1990 00:00:00 GMT
pragma:no-cache
server:GSE
status:200 OK
version:HTTP/1.1
x-content-type-options:nosniff
x-frame-options:SAMEORIGIN
x-xss-protection:1; mode=block

然后,如果我尝试在单独的浏览器页面中下载丢失的图像,它会给我 3 个“302 临时移动”请求,最后是一个“200 OK”,它给出了图像。

4

0 回答 0