MIME 消息无效 AWS SES 由于 MIME 消息无效而拒绝它
Posted
技术标签:
【中文标题】MIME 消息无效 AWS SES 由于 MIME 消息无效而拒绝它【英文标题】:Invalid MIME Message AWS SES is rejecting it due to invalid MIME message 【发布时间】:2012-04-07 21:08:49 【问题描述】:我正在尝试通过 AWS 简单电子邮件服务发送附件,我可以让它发送没有附件的原始电子邮件,但是当我尝试使用附件时它总是失败。我是否正确构建了我的 MIME 消息?
好的,这是正确发送的 MIME:
From: test@example.com
To: test@example.com
Subject: Test Email
Content-Type: multipart/mixed;
boundary="_003_97DCB304C5294779BEBCFC8357FCC4D2"
MIME-Version: 1.0
--_003_97DCB304C5294779BEBCFC8357FCC4D2
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Hello, This is a test email.
当我附加附件时发送失败:
From: test@example.com
To: test@example.com
Subject: Test Email
Content-Type: multipart/mixed;
boundary="_003_97DCB304C5294779BEBCFC8357FCC4D2"
MIME-Version: 1.0
--_003_97DCB304C5294779BEBCFC8357FCC4D2
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Hello, This is a test email.
--_003_97DCB304C5294779BEBCFC8357FCC4D2
Content-Type: text/txt; name="test.txt"
Content-Description: test.txt
Content-Disposition: attachment; filename="test.txt";
Content-Transfer-Encoding: base64
VGhpcyBpcyBhIHRlc3QgYXR0YWNobWVudC4=
--_003_97DCB304C5294779BEBCFC8357FCC4D2
有什么明显的错误吗?
我通过对整个消息进行 base64 编码并将其添加到此 URL 的末尾来构建调用:
Action=SendRawEmail&Destinations.member.1=test%40example.com&RawMessage.Data=base64 encoded MIME Message
回答:
MIME 文件存在两个问题。首先
尾随边界不应该在那里,因为它显然是在寻找 MIME 消息的另一个方面,例如另一个附件。
定义为“text/txt”的Content-Type实际上应该是“text/plain”
因此,这意味着通过这两个更改,您会得到这个有效的 MIME 消息:
From: test@example.com
To: test@example.com
Subject: Test Email
Content-Type: multipart/mixed;
boundary="_003_97DCB304C5294779BEBCFC8357FCC4D2"
MIME-Version: 1.0
--_003_97DCB304C5294779BEBCFC8357FCC4D2
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Hello, This is a test email.
--_003_97DCB304C5294779BEBCFC8357FCC4D2
Content-Type: text/plain; name="test.txt"
Content-Description: test.txt
Content-Disposition: attachment; filename="test.txt";
Content-Transfer-Encoding: base64
VGhpcyBpcyBhIHRlc3QgYXR0YWNobWVudC4=
【问题讨论】:
【参考方案1】:MIME 文件存在两个问题。首先
尾随边界不应该在那里,因为它显然是在寻找 MIME 消息的另一个方面,例如另一个附件。
定义为“text/txt”的Content-Type实际上应该是“text/plain”
因此,通过这两个更改,您会得到这个有效的 MIME 消息:
From: test@example.com
To: test@example.com
Subject: Test Email
Content-Type: multipart/mixed;
boundary="_003_97DCB304C5294779BEBCFC8357FCC4D2"
MIME-Version: 1.0
--_003_97DCB304C5294779BEBCFC8357FCC4D2
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Hello, This is a test email.
--_003_97DCB304C5294779BEBCFC8357FCC4D2
Content-Type: text/plain; name="test.txt"
Content-Description: test.txt
Content-Disposition: attachment; filename="test.txt";
Content-Transfer-Encoding: base64
VGhpcyBpcyBhIHRlc3QgYXR0YWNobWVudC4=
【讨论】:
以上是关于MIME 消息无效 AWS SES 由于 MIME 消息无效而拒绝它的主要内容,如果未能解决你的问题,请参考以下文章
boto3 ses InvalidParameterValue 错误由于 unicode 字符