10
votes

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.

1
Are you using the SES API, or the SES-SMTP interface to send your emails?E.J. Brennan
I'm using the SES-SMTP interface.Tom Albers
I don't think you can. You'd have had to store the message ID and subject at send time.ardila
That is what I was getting at, if you use the SES-API, then you can get the message id for sent messages - that is what you can then use to lookup from a sent-messages table/database/folder to find the subject (assuming you had previously stored it before sending).E.J. Brennan
@E.J.Brennan you can get it from the SMTP response as well 250 Ok <Message ID> (see docs.aws.amazon.com/ses/latest/DeveloperGuide/…)ardila

1 Answers

10
votes

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.