【问题标题】:Embedding attached data in MIME, to the HTML portion of the email. Not linking to the attached file将 MIME 中的附加数据嵌入到电子邮件的 HTML 部分。未链接到附件
【发布时间】:2019-02-19 04:12:30
【问题描述】:

我已经生成了这个通过 aws-ses 发送的 MIME 数据。在整个 MIME 数据中

Content-Type: multipart/mixed;boundary=T4nu9J8b
From: <noreply@noreply.in>
To: <myemail@gmail.com>
Subject: Your Image

--T4nu9J8b
Content-Type: multipart/alternate;boundary=R5I0TJcF

--R5I0TJcF
Content-Type: text/html;charset=utf-8

<h1> Hi!!! </h1><p>Here is your progress report </p><br/> <img alt="Embedded Image" src="cid:testimage.png"/>
--R5I0TJcF
Content-Type: text/plain;charset=utf-8

This is the plain text version of the message.
--R5I0TJcF--
--T4nu9J8b
Content-Type: image/png
Content-Transfer-Encoding: base64
Content-Disposition: attachment ;filename="testimage.png"

iVBORw0KGgoAAAANS...
--T4nu9J8b--

我收到了电子邮件,但图像未嵌入 MIME 的 html 部分 img 标签链接到附件

HTML 代码

<img alt="Embedded Image" src="cid:testimage.png"/>

MIME 附件

--T4nu9J8b Content-Type: image/png Content-Transfer-Encoding: base64 Content-Disposition: attachment ;filename="testimage.png"

iVBORw0KGgoAAAANS...
--T4nu9J8b--

结果电子邮件

【问题讨论】:

    标签: amazon-web-services email mime amazon-ses


    【解决方案1】:

    图片附件部分需要Content-ID

    --T4nu9J8b
    Content-Type: image/png
    Content-ID: <idname>
    Content-Transfer-Encoding: base64
    Content-Disposition: attachment ;filename="testimage.png"
    
    iVBORw0KGgoAAAANS...
    --T4nu9J8b--
    

    注意:Content-ID 名称应放在尖括号中,如给定的那样

    使用相同的 Content-ID 将其嵌入到标签中(不带尖括号)

    <img alt="Embedded Image" src="cid:idname"/>
    

    这应该允许附加图像显示到 html 中!

    完整资源:http://www.faqs.org/rfcs/rfc2387.html

    类似的问题 Embedding attached images in HTML emails 但我找不到准确的答案。我也会在那里发布相同的内容。

    【讨论】:

      猜你喜欢
      • 2019-04-06
      • 2011-09-03
      • 2014-08-21
      • 2011-06-07
      • 2013-09-09
      • 2020-06-30
      • 1970-01-01
      • 2010-10-29
      • 1970-01-01
      相关资源
      最近更新 更多