Identify original email from Complaint SES notification - amazon-web-services

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

Related

Should AWS SES bounce emails be notified by one or more methods

AWS Simple Email Service (SES): Bounce Email Notification/Feedback
I have both the following methods set up in the AWS Console to receive information about bounce emails:
1) Email Feedback forwarding - to send any bounce email details back to the sender. This is the domain or email that is managed in the AWS console and is verified. Hence the From/Source is a valid user email with a mailbox
2) SNS Notification for bounce emails - This is used to trigger a lambda function and the intention here is to get a notification on the emails that bounced and was sent from an address of a verified domain that doesn't have a mailbox e.g noreply#domain. This is automated from the software.
The lambda function forwards this notification to the reply emails that are part of the Header in the notification.
The reply emails may also contain personal email addresses that are not necessarily managed in the AWS console. Therefore the lambda is basically forwarding the notification back to all the reply emails of the user.
My issue here is that the above works but sometimes I get notifications using both methods.
Should AWS only choose one of the above two when dealing with bounces? Can someone please shed some light on this?
Thank you
Try creating a Deliverability dashboard, it now provides excel sheet to download and track your bounce emails.
https://docs.aws.amazon.com/ses/latest/DeveloperGuide/bouncecomplaintdashboard.html
The AWS documentation is not super clear with respect to simultaneously using multiple methods for bounce email notification. However, the following under 'Disabling Email Feedback Forwarding' does indicate that using more than one method for bounce notification will result in multiple notifications.
https://docs.aws.amazon.com/ses/latest/DeveloperGuide/notifications-via-email.html
In my case (using the above two methods for bounce email notification), When I use the SES via SMTP interface from an Asp.Net app, I get two bounce email notifications, one via SNS and the other via the Email Feedback Forwarding method. In Addition when I use an email client like MSOutlook, then I only get one bounce notification which is expected
because it's not using SES.
My solution:
Option 1:
Use both methods for SES.
The Email Feedback Forwarding method will be responsible for delivering the notification to a verified email eg user#mycompany.com with a mailbox.
The lambda triggered by the SNS method will have a filter that will only process notifications where the source is norepy#mycompany.com.
Hence this will prevent duplicates and will also allow me to forward bounce email notifications to other reply-to emails (set by the web app in the header) that are not verified in my AWS.
Option 2:
Disable Email Feedback Forwarding Method and process all notifications via lambda triggered by SNS Method.

Amazon SES - notifications for email verification

We use Amazon's SES service, and have set up Topics and Subscriptions under SNS (Simple Notification Service) so that we get notification emails when an email is bounced or successfully delivered. That's all working fine.
We sometimes send emails via SES on behalf of one of our partners, and before we can do that we need to verify their email address. The process is that the system asks SES to send out a verification email to the person saying "Example.com wants to send emails on your behalf, is that ok?", with a link for them to click. If they click it, then that email is marked as Verified within SES, and we can use it as a from address.
What I can't work out is how to automate the process of knowing whether they've clicked the link yet. I can log in to the AWS dashboard, and go and look at the list of verified email addresses, but i'd like to make it an automated process.
What would be ideal is if it worked the same way as bounces & deliveries: that i set up a "Verification" topic, and subscribe to it so we get an email like we do with bounces and deliveries. Then, the scheduled job that deals with incoming email notifications can say "Aha, this is a verification email for foobar#example.com: I'll mark their account as 'ses-verified'".
Does anyone know if it's possible to set this up? All the docs on the SES site just talk about bounces, deliveries and complaints.
thanks, Max
You can use the GetIdentityVerification api call in the SES part of the awssdk:
https://docs.aws.amazon.com/ses/latest/APIReference/API_GetIdentityVerificationAttributes.html
You could do this in a serverless way by having a lambda function do the check, and expose the lambda as an API endpoint to your application (among other ways).
Alternatively you could just try to send a single test email to a test/internal email address and check if it gives you an error - if its not verified, it will return an error immediately when you try to do the send.
EDIT:
If you want to use the CLI instead:
aws ses get-identity-verification-attributes --identities "mailbox#thedomain.com"

How to track a specific email using Amazon's Simple Email Service?

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).

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.
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.

Amazon SES Notifications (SNS) not working

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.