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
demandé il y a 4 ans390 vues
1 réponse
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
répondu il y a 4 ans

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions