如何创建带有与大多数邮件客户端兼容的嵌入图像的电子邮件 [英] How to create an email with embedded images that is compatible with the most mail clients

查看:105
本文介绍了如何创建带有与大多数邮件客户端兼容的嵌入图像的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们创建了一个系统,该系统允许将图像嵌入到待发电子邮件中.

We have created a system that allows embedding an image in an outgoing email.

这是我们的系统创建的原始消息.此示例包含一个图像附件和一个嵌入式图像.

Here is the original message our system creates. This example contains an image attachment and an embedded image.

Mime-Version: 1.0
From: ...
To: ...
CC: 
Subject: test
x-sender: ...
x-mailer: ...
Content-Type: multipart/mixed; boundary="-------------...A128803765634794"

---------------...A128803765634794
Content-Type: multipart/related; boundary="-------------...B128803765634796"

---------------...B128803765634796
Content-Type: text/html; charset="UTF-8"

<p style="margin: 0; padding: 0"><img src="cid:083.gif" alt="" /></p>

---------------...B128803765634796
Content-type: image/gif; name="083.gif"
Content-ID: <083.gif>
X-Attachment-Id: 083.gif
Content-Disposition: Embedded; filename="083.gif"
Content-transfer-encoding: base64

............................................................................
............................................................................
......................................................
---------------PineappleCodeB128803765634796--
---------------PineappleCodeA128803765634794
Content-type: image/gif; name="waiting.gif"
Content-Disposition: Attachment; filename="waiting.gif"
Content-transfer-encoding: base64

............................................................................
............................................................................
......................................................
---------------PineappleCodeA128803765634794--

我应该添加另一个标头还是应该遵循的规则?

Is there another header I should add or rule I should follow?

我注意到一件事 ...我想这是我的问题和Gmail的一部分.但无论如何,我想让它停止发生

I noticed one thing... I would guess that it is part my issue and part Gmails. but at any rate I would like to make it stop happening

在Gmail中收到电子邮件后,我会收到

When the email is received into Gmail I get

不显示图像.
在下方显示图片-始终显示...的图片

Images are not displayed.
Display images below - Always display images from ...

然后将嵌入的图像显示为图像附件(就像我的其他图像附件一样)

The embedded image is then shown as an image attachment (just like my other image attachment)

我单击下面的显示图像,并且我的图像显示在电子邮件的正文中,但未从附件"部分中删除.

I click Display Images Below and my image is shown in the body of the email but not removed from the Attachments section.

如果我回到收件箱并返回到电子邮件,则看起来不错.

If I go back to my in box and back to the email it looks fine.

我不明白为什么要这么做.它不是链接的图像(来自外部URL),并且当将嵌入式图像从Gmail发送到Gmail时不会发生.那就是让我认为自己做错了什么,恐怕这可能会影响其他接收者.

I do not see why it does that. It it not a linked image (from external URL) and it does not happen when sending embedded images from Gmail to Gmail. That is what makes me think I might be doing somthing wrong and I am afraid that it may affect other recipients.

推荐答案

我已经成功使用了与您使用的标题完全相同的标头,但有以下区别:

I've had success with exactly the same headers as you're using, with the following differences:

  • Embedded is not a valid value for the Content-Disposition header. attachment should be fine. inline should also be fine, though I've usually seen attachment for multipart/related embedded images.

Content-ID标头的值应为与消息相同的格式- id ,它反过来看起来很像一个电子邮件地址. <083.gif@yourmailer>与大多数邮件发件人合作的可能性更高.

The value of the Content-ID header is supposed to be in the same format as a message-id, which in turn looks very much like an email address. <083.gif@yourmailer> has a better chance of working with most mailers.

这篇关于如何创建带有与大多数邮件客户端兼容的嵌入图像的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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