AWS SES S3 process inbound email

Radu picture Radu · Jan 11, 2016 · Viewed 10.7k times · Source

I'm working on a publish by email system based on AWS SES. For all incoming emails I've set routing to save messages in an S3 bucket so I can asynchronously process them. The problem I have is that the messages are saved in the S3 bucket in a raw format: headers, email body, etc + the encrypted attachment (a huge string) - all in a single file.

Is there a way to break the email message apart form the attachment and save both in separate files at AWS SES level? I'm trying to get the data in the format I need straight from AWS and avoid adding another processing step to the process.

If AWS SES doesn't provide such a feature, what would be the proper way to process these messages to obtain the result described above?

Answer

Mark B picture Mark B · Jan 12, 2016

It doesn't look possible to have SES automatically split up the email for you. As per the documentation here:

Amazon SES provides you the raw, unmodified email, which is typically in Multipurpose Internet Mail Extensions (MIME) format.

I would use S3 or SNS to trigger a Lambda function whenever SES puts a new email file to S3. The Lambda function could split the file however you wish, then write those new files to another S3 bucket.