无效的MIME消息由于MIME消息无效,AWS SES拒绝该消息

时间:2012-03-23 09:45:55

标签: validation email mime amazon-ses

我正在尝试通过AWS Simple Email Service发送附件,我可以让它发送没有ATTACHMENTS的原始电子邮件,但是当我尝试使用附件时,它总是会失败。我是否正确构建了我的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文件存在两个问题。首先

  • 尾随boundery不应该在那里,因为它显然正在寻找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 个答案:

答案 0 :(得分:0)

MIME文件存在两个问题。首先

  • 尾随boundery不应该在那里,因为它显然正在寻找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=