Skip to content

How can I store a copy of outbound emails (sent via JavaMailSender using Amazon SES) directly into an S3 bucket?

0

I am using Amazon SES to send outbound emails from a Java Spring Boot application using JavaMailSender (SMTP interface). I want to automatically store a copy of every sent email (including headers and attachments) in an S3 bucket for archiving.

In the SES console, I created a configuration set, but I don’t see any option to add an S3 destination under "Add destination." The only available options are Event Bridge, SNS, Kinesis, and CloudWatch.

From what I understand, the S3 action is available only for inbound email (receipt rules), not outbound sends. I also found that the new Mail Manager archiving feature supports outbound archiving, but I am not sure if that is the only option.

Can you please confirm:

Is there a direct way (without Mail Manager) to automatically store outbound emails to S3 using SES?

If not, is the recommended approach to programmatically store the Mime Message to S3 using the AWS SDK after sending the email?

Thanks in advance for your guidance.

1 Answer
0

Yes, you're correct in your understanding.

For outbound emails sent through Amazon SES, there are two main approaches you can take:

  1. Use SES Email Archiving (Mail Manager): This is the built-in AWS solution for archiving both sent and received emails. When you send emails through a configuration set with archiving enabled, those emails will be automatically archived. You can then export these archived messages to an S3 bucket as needed.

  2. Programmatically store the email in S3: Since you're already creating the email in your Java Spring Boot application using JavaMailSender, you can implement a solution to store a copy of each email in S3 before or after sending it. This would involve:

  • Capturing the complete MIME message (including headers and attachments)
  • Using the AWS SDK for Java to upload the message to your S3 bucket
  • Adding appropriate object key prefixes for organization

The programmatic approach gives you more control over the storage format and organization but requires you to implement and maintain the code. You would use the AWS SDK's putObject method to store the email content in your S3 bucket.

If you need a fully managed solution without additional code, the SES Email Archiving (Mail Manager) feature would be the recommended approach. Otherwise, implementing the programmatic storage solution alongside your existing email sending code would be the most direct way to achieve your goal.
Sources
Email archiving - Amazon Simple Email Service
Deliver to S3 bucket action - Amazon Simple Email Service
Community | Save cost by directly uploading objects in S3 Glacier

answered a month ago
AWS
SUPPORT ENGINEER
reviewed a month ago
AWS
SUPPORT ENGINEER
revised a month 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.