2012-03-23 130 views
0

我试图通过AWS简单电子邮件服务发送附件,并且我可以让它发送没有附件的原始电子邮件,但是当我尝试使用附件时总是失败。我是否正确构建了我的MIME消息?无效的MIME消息由于无效的MIME消息,AWS SES拒绝它

好了,所以这里是发送正确的MIME:

From: [email protected] 
To: [email protected] 
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: [email protected] 
To: [email protected] 
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 contruct电话:

Action=SendRawEmail&Destinations.member.1=test%40example.com&RawMessage.Data={base64 encoded MIME Message} 

答:

有与MIME文件的两个问题。第一

  • 尾随boundery不应该是有,因为它明显地寻找MIME消息的另一个方面,例如另一个附件。

  • 其定义为“文本/ TXT”内容类型实际上应该是

因此与这两个变化意味着你得到这个MIME消息,其作品“text/plain的”:

From: [email protected] 
To: [email protected] 
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= 

回答

0

MIME文件存在两个问题。第一

  • 尾随boundery不应该在那里,因为它显然寻找MIME消息的另一个方面,例如另一个附件。

  • 其定义为“文本/ TXT”内容类型实际上应该是

因此与这两个变化意味着你得到这个MIME消息,其作品“text/plain的”:

From: [email protected] 
To: [email protected] 
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=