Mirakurun / aws-lambda-ses-s3-email-forwarder

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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AWS Lambda SES S3 Email Forwarder

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.

Architecture Diagram

Diagram

Features

  • 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

Requirements

  1. Domain name
  2. AWS account
  3. Unsanboxed Amazon SES account
  4. Verify your domain

Installation

npm install

Configuration

Create the following file inside the config folder.

config.js

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
};

Packaging

serverless package

Deployment

serverless deploy --package .serverless

Setup Email Receiving

SES Rule set

Create a receipt rule set

  1. Create recipients
  2. Create 2 actions in this exact order. S3 first, then Lambda.
    1. 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"
    2. Lambda action
      • Lambda function: Choose the function that you created during deployment.
      • Invocation type: Choose "Event"
      • SNS Topic - Choose "None"

About

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.


Languages

Language:JavaScript 100.0%