Set Up a Custom Email with Your Domain Using Amazon SES, S3, and Lambda
From edge computing to sustainability—cloud is evolving fast.
📧 Set Up a Custom Email with Your Domain Using Amazon SES, S3, and Lambda
Part 1: Receive Emails Using Amazon SES + S3
What You'll Need
- A domain name (e.g., abc123.com) configured in Route 53
- Access to AWS Console: SES, S3, Route 53
Step 1: Verify Domain in SES
- Go to Amazon SES → Verified identities
- Click Create identity, select Domain, and enter your domain
- Use Route 53 to auto-add DNS records or manually add TXT/DKIM if using another provider
- Wait for domain to show as Verified
Step 2: Create S3 Bucket to Store Emails
- Go to S3 → Create bucket
- Name it something like
abc123-emails
- Disable public access and enable encryption
Step 3: Set MX Record in Route 53
- Go to Route 53 → Hosted Zones → abc123.com
- Create MX record:
10 inbound-smtp.us-east-1.amazonaws.com
Step 4: Create Email Receiving Rule in SES
- Go to SES → Email Receiving → Rule Sets
- If no rule set exists, create one and activate it
- Click Create rule:
- Recipient:
me@abc123.com
or @abc123.com
- Action: S3 → Choose your bucket
Part 2: Forward Emails Using Lambda and Send via SES SMTP
Step 1: Create IAM Role for Lambda
- Go to IAM → Roles → Create role
- Select service: Lambda
- Attach policies:
AmazonS3ReadOnlyAccess, AmazonSESFullAccess, AWSLambdaBasicExecutionRole
Step 2: Create Lambda Function
- Go to Lambda → Create function
- Use Python 3.12 and assign the role created above
- Paste this code:
import boto3
import email
import os
s3 = boto3.client('s3')
ses = boto3.client('ses')
FORWARD_TO = "your@gmail.com"
def lambda_handler(event, context):
record = event['Records'][0]
bucket = record['s3']['bucket']['name']
key = record['s3']['object']['key']
response = s3.get_object(Bucket=bucket, Key=key)
raw_email = response['Body'].read()
ses.send_raw_email(
Source=FORWARD_TO,
Destinations=[FORWARD_TO],
RawMessage={'Data': raw_email}
)
return {'status': 'Email forwarded'}
Step 3: Add S3 Trigger
- In the Lambda function, add S3 trigger for the email bucket
- Set event type:
Object Created
- Prefix (optional):
inbox/
Step 4: Send Emails Using SES SMTP
- Go to SES → SMTP settings → Create SMTP credentials
- Use these settings in your mail client:
- SMTP:
email-smtp.us-east-1.amazonaws.com
- Port: 587
- Username/Password: from SES
Step 5: Improve Deliverability
- Enable DKIM signing under SES → Domains
- Add SPF record to Route 53:
"v=spf1 include:amazonses.com -all"
🎉 Done!
Your email setup is now live using your domain name, all managed serverlessly with Amazon SES, S3, and Lambda!