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.
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.
Related
Im using AWS Lambda for sending emails by Amazon SES.
Each time that the request send_email succeeds I got the message id like confirmation.
But now, I want to use somehow this messageId. For example to know if this message concretelly get delivered or bounced.
CloudWatch offers me metrics, with the number of delivered or bounced messages but I want to look throught each one.
¿Is there any statement that allows to know the state of a message by id?
Due to the asynchronous nature of SMTP and how mails are being routed, you can't have this information immediately when sending an e-mail (via SES or otherwise).
However, AWS provides a feedback system which notifies an SNS topic when a message is delivered, bounced, or a complaint was received.
While the documentation is very detailed, the general idea is that you subscribe your own lambda(s) to the configured SNS topic(s) and you can then handle these events as you see fit (i.e. persist data on DynamoDB, call your unsubscribe API and so on).
I have a contact us service which is triggered by users from a website.
Whenever user sends message, an email is sent to admin to notify about new contact. This email is in the form a json given below,
Is there a way to have it as a formatted email? I have figured out one method that is write a lambda to trigger SES. Is there a better method?
When SNS sends an email, it sends the entire notification and not just the message attribute.
You cannot format message or only send some of the attributes.
Your message is in JSON format, have you tried the subscription protocol "Email" instead of "Email-JSON"? It should give the same result but just in clear text. I dont know if that will help your situation.
An alternative would be to send the notifications to Lambda which can then send a formattet email via SES. You can either send the messages directly to Lambda, or via a SQS for resilience (see this discussion).
I am successfully sending emails using the AWS SDK for Java and I can also retrieve the Message ID for each email. Now I need to track the email to see if it was successfully delivered or it bounced.
Is there a way to use that Message ID to track the status of a specific email?
I have explored the getSendStatistics API but this only gives statistics for all emails, ideally I need something to track individual emails.
Is there a way to track individual emails using an SES API or even a Simple Notification Service API?
You can use Amazon SES Notifications through Amazon SNS for that. You create SNS topic subscriptions depending how you want to track the deliveries and bounces.
The SNS notification content itself contains a mail object that has the message ID, a delivery object for successful deliveries, a bounce object for bounced recipients and a complaint object for complained recipients (if any).
Is there a way to identify the originating email from a complaint notification in Amazon's SES? For example if we have 3 different mailing groups all sending different emails, and the recipient doesn't like 1 of them and reports it as spam, is there anything in the SES notification that would help us identify which email, and therefore which mailing group, we need to act on?
Yes, there is! From the docs:
Monitor your bounces and complaints and remove any bounced or
complained recipient addresses from your mailing list. You can be
notified of bounces and complaints in one of two ways: by email or by
Amazon Simple Notification Service (Amazon SNS) notifications. For
more information, see Monitoring Using Amazon SES Notifications.
Basically you can receive an email of a SNS notification (email, SMS, queue, etc.) to handle this. I would suggest SNS as it's way more flexible and the cost shouldn't be a problem (considering you don't have loads of complaints, of course!). Take a look:
Monitoring Using Amazon SES Notifications
EDIT: to identify the specific message the complaint is about, you'll need to store the unique ID created by SES when you send the message. From this AWS blog post:
Amazon SES assigns a unique message ID to each email that you
successfully submit to send. When Amazon SES receives a bounce or
complaint message from an ISP, we forward the feedback message to you.
I have used complaints treatment but never paid attention to this message ID. Anyway, looks like the path to follow.
Yes, you can do that
For each of the email that you send out via the SES, it gives back a messageID which is unique for every message that goes out (In your case it will be unique for each of the 3 mails that you send to the same recipient).
You need to persist that somewhere when you send emails.
Now when a complain occurs SES gives back the original messageId that this particular email was sent with.
And this way you can look up your local persistance and find out which of the 3 emails did the user complained for
I am still in the sandbox of Amazons SES trying set a bounce email handler.
I am using the mailbox simulator to test a bounce/complaint email.
I have created a SNS topic (and I have subscribed to receive notifications from this topic):
I have selected this topic to receive bounce email notifications, then I have disabled email notifications:
However, when I send e-mails to bounce#simulator.amazonses.com from SES I still receive a bounceback e-mail and there aren't updates in the SNS topic.
I will try to make this issue clearer with some screenshots.
It can happen outside the sandbox too.
I did not realise that the Amazon SES console can set a SNS bounce/complaint topic for the domain, as well as a separate SNS setting for every verified email address.
So each verified email address can have its own different SNS bounce/complaint topic if you want! If you want them all the same, you have to go and set them all up in the console: tell each one to use SNS, otherwise they have 'Email Feedback Forwarding' set to "enabled" and this will override the setting at domain level.
The configurations of not receiving "Email Feedback" and sending Bounce emails to SNS Topic were set to my Domain example.com.
In my Verified Emails I had myself#example.com and I was sending e-mails with it.
It happens that my verified e-mail itself had these configurations too, so when I set them to be like those of my domain, everything started working.
If I had tried to send e-mails with anythingelse#example.com it would've worked.
Email Feedback Forwarding and SES notifications via Amazon SNS are exposed as two separate mechanisms. The linked documentation describes as much:
You must receive bounce and complaint notifications either by email or
through Amazon SNS – The default method is by email, through a feature
called email feedback forwarding.
Since you've shown that Email Feedback Forwarding is disabled, you are likely still receiving bounce notifications via your verified SNS email subscription.
To test, try removing your email subscription from the SNS topic and then sending an email to the bounce simulator again. To test further, you could subscribe a different email address or even an SQS queue to verify that bounce notifications are still being published.