A Node.js Lambda function that utilizes Amazon SES to forward incoming emails to an email address inbox. Setup Amazon SES to receive emails and deliver to a S3 bucket, then invoke lambda to forward the email to your email of choice.
- Serverless... no servers required because of Lambda.
- Cheap... can cost as low as a few cents.
- Parse email attachments. Saves attachments to S3 and insert download links into email. Avoid SES email size limitations.
- Receiving email: 30 MB
- Sending email: 10 MB
npm install
Create the following file inside the config folder.
exports.config = {
attachmentPrefix: 'attachments/', // Attachment folder
bucket: '', // S3 bucket
cloudFront: '', // CloudFront distribtion domain name for S3 bucket (optional and you must setup this yourself first)
forwardTo: [], // Email address destination
from: '', // The email address that is sending the email.
keyPrefix: 'email/', // Key prefix for S3 bucket
region: '', // The region to send service requests to (not required if using CloudFront)
sendingRate: 1, // How many messages per second is allowed to be delivered to SES
};
serverless package
serverless deploy --package .serverless
- Create recipients
- Create 2 actions in this exact order. S3 first, then Lambda.
- S3 action
- S3 bucket - The name of the Amazon S3 bucket to which to save received emails.
- Object key prefix - A key name prefix to use within the Amazon S3 bucket. (for example, email/)
- Uncheck encrypt message (NOT RECOMMENDED because S3 client-side encryption is currently not supported for JavaScript. See documentation)
- SNS Topic - Choose "None"
- Lambda action
- Lambda function: Choose the function that you created during deployment.
- Invocation type: Choose "Event"
- SNS Topic - Choose "None"
- S3 action