This is a simple Lambda function for enhancing AWS SES with similar functionality to Postfix's virtual alias domains.
The documentation for this project is incomplete. At some point, I hope to finish it and write a blog article. For now, certain advanced users may still find the code and instructions below handy.
- Install and configure the AWS CLI, yarn, and git.
- Clone this repository.
- Copy
config.sh.example
toconfig.sh
and replace the required values:StackName
: the name of the AWS CloudFormation stack to create during deployment (default: "Reba")S3BucketArtifacts
: the name of the S3 bucket where your Lambda code zip artifacts will be stored during deploymentS3PrefixArtifacts
: the prefix within that S3 bucket for storing the code artifacts (default: "cloudformation/reba")S3BucketEmail
: the name of the S3 bucket that you will configure SES to store the raw emails in for processing.S3PrefixEmail
: the prefix within that S3 bucket for storing the email (default: "ses/forwarding/")S3PathConfigBackups
: an optional S3 path for storing a dated backup copy of the latest config.ts upon deployment
- Copy
src/config.example.ts
tosrc/config.ts
and edit it with your domain alias rules. - Run
./deploy.sh
to package and deploy the function to AWS.
If all goes well, the function will be ready. If you log into the AWS console, you should find a CloudFormation stack
named Reba
(or whatever you changed the StackName
to in config.sh
). This stack should contain a Lambda function
named <StackName>-ProcessEmail
. Then you will need to configure your incoming SES rules to execute the function.
There are various ways to configure SES depending on your goals. What follows is one possible configuration. Assume
that you have already configured SES to receive mail for your domain mydomain.com
. You could then add a rule for
that domain to your currently active SES Email Receiving Rule Set (first creating a new rule set if necessary) with
the following configuration:
- Enabled: checked
- Enable spam and virus scanning: checked
- Recipient: mydomain.com
- Actions:
- S3: specify the same bucket and prefix that you configured for deployment
- Lambda: choose the
<StackName>-ProcessEmail
function created by deployment - Bounce: choose the "550 5.1.1 Mailbox does not exist" template and specify
[email protected]
as the reply sender
Make sure your AWS credentials are in your environment, store a valid SES Lambda event in src/event.json
, then run:
yarn build
source config.sh
SuppressSend=yes node build/test.js