Stay in the loop! Subscribe to our mailing list.

Get updates, exclusive content, and more! Subscribe now for valuable insights and notifications. Join our community!

Published on July 18, 2023

How to Use Amazon SES to Receive Inbound Emails and Store Them on Amazon S3

In today's digital age, email communication plays a crucial role in various business processes. Whether it's receiving customer inquiries, processing orders, or managing subscriptions, having a reliable system for handling inbound emails is essential. Amazon Simple Email Service (SES) offers a robust and scalable solution for managing email communications. In this blog post, we will explore how you can leverage Amazon SES to receive incoming emails and seamlessly store them on Amazon S3, providing a secure and scalable storage solution.

1. Set Up Amazon SES

Before you can start receiving and storing inbound emails, you need to set up Amazon SES. Let's walk through the process:

a. Create an Amazon SES account:

  • If you don't have an Amazon Web Services (AWS) account, sign up for one at AWS Console.
  • Once you have an account, navigate to the SES service and create an account.

b. Verify your domain or email addresses:

  • To receive emails using Amazon SES, you need to verify the domain or email addresses you want to use. Verification ensures that SES can receive emails on your behalf.
  • In the SES console, navigate to Email Addresses under Identity Management in the sidebar.
  • Click on Verify a New Email Address or Verify a New Domain.
  • Follow the instructions provided to complete the verification process.

c. Configure DNS settings:

  • To enable SES to handle your email traffic securely, you need to update your DNS settings with the necessary records provided by SES. These records include TXT and MX records that authenticate your domain.
  • In the SES console, go to the Domains page under Identity Management.
  • Select the verified domain for which you want to configure DNS settings.
  • Follow the instructions provided to add the required DNS records to your domain's DNS settings. This process varies depending on your DNS provider, but you typically need to add TXT and MX records.

2. Create an Amazon S3 Bucket

To store incoming emails, you'll need an Amazon S3 bucket. Let's create a new S3 bucket:

a. Navigate to the Amazon S3 console:

  • Sign in to your AWS account at AWS Console.
  • In the AWS Management Console, search for S3 and select the Amazon S3 service.

b. Click on "Create bucket":

  • Click the Create bucket button.
  • Provide a unique name for your bucket. For example, you can name it "inbound-emails-bucket."
  • Choose the appropriate region for data storage based on your preference and requirements.

c. Configure bucket settings:

  • For simplicity, you can stick with the default settings. However, you may consider enabling Server access logging and Default encryption for enhanced security.

d. Enable versioning (optional):

  • Enabling versioning allows you to track and manage different versions of your stored emails if needed.
  • In the S3 console, select your bucket and go to the Properties tab.
  • Click on Versioning and enable it.

e. Update Bucket Policy:

  • To allow SES to deliver emails to the S3 bucket, you need to update the bucket policy.
  • In the S3 console, select your bucket and go to the Permissions tab.
  • Click on Bucket Policy and add the following policy to your bucket policy document, replacing "YOUR_BUCKET_NAME" with the actual name of your bucket:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowSESPuts", "Effect": "Allow", "Principal": { "Service": "" }, "Action": "s3:PutObject", "Resource": "arn:aws:s3:::YOUR_BUCKET_NAME/*", "Condition": { "StringEquals": { "aws:Referer": "YOUR_ACCOUNT_ID" } } } ] }

3. Configure Amazon SES to Store Emails on Amazon S3

Now, let's configure SES to store inbound emails on S3. Follow these steps:

a. Create an Amazon SES receipt rule that sends inbound emails to the S3 bucket:

  • Open the Amazon SES console in your web browser.
  • In the navigation pane, under All rule sets, choose Email Receiving.
  • Choose the active rule set you want to add the rule to.
  • Choose Create Rule.
  • Enter a unique rule name for your reference.
  • If your use case requires TLS or spam and virus scanning, choose the respective options ("Require TLS" or "Enable spam and virus scanning"). To make this rule active, select the Enabled checkbox.
  • Choose Next.

b. Specify the recipients and action to store emails in the S3 bucket:

  • To store emails sent to specific verified domains, choose Add Recipient conditions and enter the email addresses as recipients. If you want to store all emails sent to all verified domains, leave this field empty. Then, choose Next.
  • Choose Add new action.
  • Select Deliver to S3 bucket.
  • Complete the following steps:
    • For S3 bucket, choose the bucket you created to store emails.
    • For Object key prefix, enter an S3 prefix where you want to store the emails. If you leave this field blank, Amazon SES stores emails at the root of the bucket.
    • (Optional) Choose Message encryption if you want Amazon SES to use an AWS Key Management Service (KMS) key to encrypt your emails.
    • (Optional) For SNS topic, select an Amazon Simple Notification Service (SNS) topic to receive notifications when Amazon SES delivers an email to the S3 bucket.
  • Choose Next.

4. Test and Monitor the Setup

After completing the configuration, it's crucial to test the setup and monitor the process for any potential issues. Let's walk through the testing and monitoring steps:

a. Send a test email:

  • Send a test email to one of the verified email addresses or domains.

b. Check the S3 bucket:

  • In the S3 console, select your bucket and navigate to the folder structure you specified.
  • Verify that the test email is stored within the expected folder.

c. Monitor the Amazon SES and S3 logs:

  • Monitor the logs provided by Amazon SES and S3 to identify any errors or anomalies in the email receiving and storage process. You can access the logs in the respective service consoles or configure AWS CloudWatch to receive notifications and alerts for any issues.

By leveraging the power of Amazon SES and S3, you can seamlessly receive inbound emails and store them securely in the cloud. This integration ensures reliable email handling, scalability, and easy access to your stored emails. Letting Amazon SES receive emails on your behalf and using Amazon S3 for storage provides a robust solution for managing your inbound emails. Implementing this setup will help streamline your email workflow and enhance your overall email management strategy.

Remember that these instructions provide a general guideline, and it's important to refer to the Official AWS documentation for detailed instructions and best practices when setting up Amazon SES and S3 integration. With the right configuration, you can unlock the full potential of email communication in your business.

Back to Home