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
已提問 4 年前檢視次數 390 次
1 個回答
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
已回答 4 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南