Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically processing the Amazon SES notifications for bounce and complaint notifications

We are using AWS SES for sending mails. Amazon SES sends bounce and complaint notifications through emails or AWS SNS. We would like to automatically process the bounce and complaint notifications (coming from email or AWS SNS) to extract the email ids, so that these emails can be removed from the original list.

One way to automate is to send these notifications to a topic in AWS SNS, then subscribe to the topic using AWS SQS and finally read the messages in the AWS SQS. SNS supports subscription over the following protocols - HTTP/HTTPS/EMail/EMail(JSON)/SMS/SQS. This is feasible, but I find it too cumbersome for a simple task of automatically processing the bounce and complaint notifications.

Is there any elegant way of tacking this problem?


I have found a blog entry from Amazon with the code in C#. Is there a better solution?

like image 299
Praveen Sripati Avatar asked Sep 14 '12 16:09

Praveen Sripati


2 Answers

I find that directly subscribing to SNS using an HTTP endpoint is the most straightforward approach. You literally have to write only a few lines of code. Here's my django example:

def process(request):
    json = request.raw_post_data              
    js = simplejson.loads(json)
    info = simplejson.loads(js["Message"])
    type = info["notificationType"]           # "Complaint" or "Bounce"
    email = info["mail"]["destination"][0]


    # do whatever you want with the email
like image 50
Raz Avatar answered Sep 28 '22 10:09

Raz


I think the way you describe IS probably the most elegant way. You already have very appropriate services in SNS and SQS that have associated SDK's in most major languages to allow you to do what you need easily. The hardest part is writing the code to update/remove the records in your mailing lists.

like image 40
Mike Brant Avatar answered Sep 28 '22 09:09

Mike Brant