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
preguntada hace 4 años390 visualizaciones
1 Respuesta
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
respondido hace 4 años

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas