In this video I will show you how to setup Simple Email Service (SES) and AWS Lambda function to have your receiving emails forwarded to any other destination. This tutorial builds upon the previous tutorial on configuring AWS SES as an SMTP service for your website.
- Have your domain setup with AWS SES (Watch my previous video tutorial)
- Make sure you are in a Region that support Email Rule sets.
- Create a Lambda Function
- Goto the Lambda Service in AWS console
- Create Function
- Give your function a name “SesForwarder” and select scratch
- Copy the index.js code from the Github Repo of @arithmitic (GitHub – arithmetric/aws-lambda-ses-forwarder: Serverless email forwarding using AWS Lambda and SES) and paste it into the index.js edit in the Lambda screen.
- Modify the defaultConfig section
- Change from email to be the SES email address that you verified
- S3 Bucket
- Forward mapping
- Click on the Configuration Tab
- Modify the General Configuration and set the memory limit to be 128 MB or 512MB and 30 second Timeout;
- This is if you may have large attachments.
- Deploy the function
- Publish the function
- Click on Permissions
- Click on the Role Name. This will open the IAM
- Click on the Policy starts with AWSLambda….
- Click Edit Policy
- Click on JSON
- Copy and Paste the code at the end
- Modify the S3-BUCKET-NAME with the name of your S3 bucket.
- Save Policy
- Back in SES console, modify the existing rule
- Add a new Lambda action under the Existing S3 Action
- Select the Lambda function you created.
- If it ask for permissions say Add Permissions.
- Verify email that you are forwarding to (in my case it is gmail.com) if your SES is still in Sandbox mode
Links from the tutorials
- Amazon Simple Email Service endpoints and quotas – AWS General Reference
- GitHub – arithmetric/aws-lambda-ses-forwarder: Serverless email forwarding using AWS Lambda and SES
All videos tutorials on the website as well as the YouTube channel aim to provide a simplified process for a specific scenario; there could be many different factors and unique use cases you may have. The tutorials may not cover every situation; so treat is as a starting point or learning concept to apply to your unique situations, and consider this inspiration but not prescription or explicit direction.