Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve message details of a bounced email via Amazon SES / SNS

I'm using Amazon SES to send email. I've also set up Amazon SNS to receive notifications when emails bounce for whatever reason. This is working fine.

In the bounce notification I receive, I can see the date, the sender and the recipient. But the subject of the mail is not listed. See example

I do see a messageId in there. Is there an API to retrieve the message details? I also looked at Amazon SQS, but I'm not sure if that will work.

like image 244
Tom Albers Avatar asked Jan 19 '16 14:01

Tom Albers


1 Answers

You can't retrieve message details by messageID after the message has been sent, as there is no API call available to do so. You would need to store relevant details about the message along with the message ID given in the successful response from SES when sending the email (either through the API or SMTP). The Developer Guide covers a similar case of retrieving the recipients, which mentions that you would need to

store a mapping between [your own] identifier and the Amazon SES message ID that Amazon SES passes back to you when it accepts the email.

This answer by an Amazonian in an SES support thread (albeit from 2012) also reinforces that you'd need to record the message ID when you send the message.

if you record the message ID, you can use the message ID to identify the [e-mail message] that bounced or complained and then update the mailing list.

like image 126
ardila Avatar answered Oct 13 '22 21:10

ardila