dealing with duplicate emails

1

I have setup SES to receive email and put them in an S3 bucket. I then have a Lambda function that processes the emails.

The problem I am seeing is that if a single email is sent to 2 or more addresses that the SES rule set is monitoring (for example, an email is addressed to user1@mydomain and user2@mydomain) then 2 identical emails get put into the S3 bucket. They have different S3 keys, but they contain the exact same email. So, when my Lambda function processes the emails, that email is processed multiple times.

Is there a way to differentiate the emails so that I process the email once for each recipient in the To: list?

Thanks for your insight.

tyarmas
asked 4 years ago380 views
1 Answer
1

I figured this out. Turns out every email has a 'Received' element that you can look at. For instance:
In python, I did the following:
mailFor = message.get('Received', [])
Then, the mailfor dict has a number of things related to the message and that includes a single email address indicating who it is for.

I was able to strip out the address from that dict and determine who it was for and then process it without having duplicates.

tyarmas
answered 4 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions