在Thunderbird中使用Content-ID和cid嵌入式电子邮件图像 [英] Using Content-ID and cid for embedded email images in Thunderbird

查看:308
本文介绍了在Thunderbird中使用Content-ID和cid嵌入式电子邮件图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个将多个文件附加到HTML电子邮件的PHP应用程序中生成电子邮件。一些文件是Excel电子表格,一些文件是需要嵌入到HTML中的公司标志,因此默认情况下会使用Content-ID和cid标识符加载附件图像。

I'm generating emails in a PHP application which attach multiple files to an HTML email. Some of the files are Excel spreadsheets, some of the files are company logos which need to be embedded in the HTML so they load by default using Content-ID and cid identifiers to refer to the attached images.

据我所见,我的语法是正确的,但图像不会内联加载(但是它们已成功连接)。

As far as I can see, my syntax is correct, but the images don't ever load inline (they are attached successfully, however).

From: email@example.com
Reply-To: email@example.com
MIME-Version: 1.0
Content-type: multipart/mixed;boundary="d0f4ad49cc20d19bf96d4adf9322d567"
Message-Id: <20150421165500.0A5488021B@server>
Date: Tue, 21 Apr 2015 12:54:59 -0400 (EDT)

--d0f4ad49cc20d19bf96d4adf9322d567
Content-type: text/html; charset=utf-8
Content-transfer-encoding: 8bit

<html>
    Html message goes here, followed by email.<br/>
    <img src="cid:mylogo" />
</html>
--d0f4ad49cc20d19bf96d4adf9322d567
Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; name=excelsheet.xlsx
Content-Description: excelsheet.xlsx
Content-Disposition: attachment;
 filename="excelsheet.xlsx"; size=24712;
Content-transfer-encoding:base64

[base64 encoded string goes here.]

--b19e863e2cf66b40db1d138b7009010c
Content-Type: image/jpeg;
 name="mylogo.jpg"
Content-transfer-encoding:base64
Content-ID: <mylogo>
Content-Disposition: inline;
 filename="mylogo.jpg"; size=7579;

[base64 encoded string goes here.]

--b19e863e2cf66b40db1d138b7009010c--

任何人都可以看到一个明显的原因,为什么图像不会按预期嵌入?

Can anybody see an obvious reason why the image won't embed as expected?

编辑

请注意,此行为对于所有电子邮件客户端都不是通用的。

Note this behaviour isn't general to all email clients. So far only noted in Thunderbird.

推荐答案

我注意到两个问题:


  1. MIME边界不一致。对于第一个附件,它是 d0f4ad49cc20d19bf96d4adf9322d567 ,然后使用 b19e863e2cf66b40db1d138b7009010c 。因此,技术上第二个附件是第一个附件的部分。

  1. The MIME-boundary is inconsistent. For the first attachment it's d0f4ad49cc20d19bf96d4adf9322d567 and then b19e863e2cf66b40db1d138b7009010c is used. Thus, technically the second attachment is "part" of the first attachment.

如果您将所有 b19e863e2cf66b40db1d138b7009010c code> d0f4ad49cc20d19bf96d4adf9322d567 Thunderbird正确识别图像附件。

If you replace all b19e863e2cf66b40db1d138b7009010c by d0f4ad49cc20d19bf96d4adf9322d567 Thunderbird correctly identifies the image attachment.

使用 multipart / related 而不是 multipart / mixed 。 (请参阅 RFC2387


多部分/相关用于指示每个消息部分是聚合整数的组件。它是由多个相互关联的组件组成的复合对象 - 通过单独显示组成部分无法实现正确的显示。该消息包括一个根部分(默认情况下是第一个),其中引用其他部分内联,这可能反过来引用其他部分。消息部分通常由Content-ID部分标题引用。 (请参阅 MIME多部分/相关的维基百科条目


这篇关于在Thunderbird中使用Content-ID和cid嵌入式电子邮件图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆