문제

I am trying to send an attachment through AWS Simple Email Service, and i can get it to send a raw email WITHOUT ATTACHMENTS, however when i try it with attachments it always fails. Have i constructed my MIME message correctly?

Ok so here is the MIME that sends correctly:

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.

When I attach the attachment is fails to send:

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

Is there anything obviously wrong?

I contruct the call by base64 encoding the whole message and adding it to the end of this URL:

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

ANSWER:

There were two issues with the MIME file. First

  • The trailing boundery shouldnt be there, as it is obviously looking for another aspect of the MIME message, eg another attachment.

  • The Content-Type which is defined as "text/txt" should actually be "text/plain"

Thus meaning with those two alterations you get this MIME message which works:

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=
도움이 되었습니까?

해결책

There were two issues with the MIME file. First

  • The trailing boundery shouldnt be there, as it is obviously looking for another aspect of the MIME message, eg another attachment.

  • The Content-Type which is defined as "text/txt" should actually be "text/plain"

Thus meaning with those two alterations you get this MIME message which works:

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=
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top