This is a simple, serverless email forwarder that uses Amazon Simple Email Service (Amazon SES). It was built using the Serverless framework, which is used to create an Amazon CloudFormation stack that includes most of the necessary assets.
Please review the Limitations of this project.
- In Amazon SES, verify the domains that you want to use to receive and forward emails.
- If you have a sandbox SES account, you must also verify the addresses to which you want to forward emails if those addresses are not included in verified domains.
- If you have not yet configured inbound email handling, you must create a new Rule Set. Otherwise, you can use an existing one.
- Rename
config.example
toconfig.js
, and adjust the configuration. - Rename
env.example
toenv.yaml
, and add the name of the Amazon SES Rule Set. - Run
sls deploy --stage prod
.
Rename env.example
to env.yaml
.
The env.yaml
file provides the Amazon SES Rule Set Name that will be used by the Serverless Framework to create the Receipt Rule that will forward the email.
# Prod Stage
prod:
ses:
ruleSetName: live-rule-set
# If a stage is not specified, the default value is used.
default:
ses:
ruleSetName: default-rule-set
It is possible to specify different Rule Set Names for different stages, but only one Rule Set can be active at a time. It is usually easier to use the same Rule Set for every stage.
Rename config.example
to config.js
.
The config.js
file specifies how emails should be forwarded.
module.exports = {
default: {
fromEmail: '[email protected]',
forwardMapping: {
'@sentto.example': [
'[email protected]',
],
},
},
};
It is possible to specify different configurations for different stages.
This script was designed to forward emails from any sender. In order to accomplish this, the From and Reply-To headers of the original message are modified to allow SES to send the email, but also to reflect the original sender.
So for a message sent from Some Guy <[email protected]>
to
[email protected]
, the From and Reply-To headers will be set to:
From: Some Guy <[email protected]>
Reply-To: [email protected]
Domains and addresses must first be verified before they can be used with this forwarder.
See Verifying Domains in Amazon SES.
This includes attachments after encoding.
See Limits in Amazon SES.
Initially, all SES users start in a sandbox environment that has a number of limitations. Users must submit a support request to have their accounts removed from the sandbox.
See Limits in Amazon SES.
This project is licensed under the terms of the MIT license.
Shout outs to these talented developers:
- Joe Turgeon (@arithmetic): https://github.com/arithmetic/aws-lambda-ses-forwarder
- Eleven41 Software Inc. (@eleven41): https://github.com/eleven41/aws-lambda-send-ses-email