2012-03-23 62 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=