GithubHelp home page GithubHelp logo

sebastiaanklippert / lambda-ses-forwarder Goto Github PK

View Code? Open in Web Editor NEW
11.0 3.0 4.0 405 KB

AWS SES Email forwarder Lambda function

License: MIT License

Go 100.00%
aws aws-lambda aws-ses golang go email forwarder

lambda-ses-forwarder's Introduction

lambda-ses-forwarder

AWS SES Email forwarder Lambda function written in Go.

This is a Lambda function to forward emails received from SES.

Setup instructions

Assuming you have SES incoming emails enabled, this function needs the following configuration.

IAM

  • Create a Lambda execution role with a policy that allows
    • s3:GetObject on a bucket you can store incoming e-mails in
    • ses:SendRawEmail to forward the email to the new destination
    • Don't forget to include the default Lambda execution policy to be able to write Cloudwatch logs

Lambda

  • Create a Lambda function with Go 1.x runtime and the execution role you have just created
  • Build this program or download a release zip and upload it as source
  • Set the exection handler name to the name of the binary (lambda_ses_forwarder_linux if you use a release)
  • Memory size can be as low as 128MB if you don't receive large mails, but 256MB or higher is recommended
  • You can configure the function by using these environment variables:
Variable name Required Description
FORWARD_FROM Yes Address1 used as FROM address when forwarding mail2
FORWARD_TO Yes Address1 used as TO address when forwarding mail
S3_BUCKET Yes Name of the S3 bucket you use to store incoming mails
S3_BUCKET_REGION No Can be set when the S3 bucket is in a different AWS region than your Lambda
S3_PREFIX No If you use a key prefix when storing mails you can enter it here

1 a single RFC 5322 address, e.g. [email protected] or My Name <[email protected]>

2 can include %s as replacer to include the original sender name, e.g. %s through my mail forwarder <[email protected]>

Important Ensure the FORWARD_FROM address is a verified address in SES and is allowed to send mail, the original FROM address will be set as Reply-To address so you can answer the mails directly.

Lambda Env

SES

  • Create a Rule Set for the incoming address or domain you want to forward emails for
  • Create a first action to store your mail in the S3 bucket from the previous steps with an optional prefix
  • Create a second action to call the Lambda function you created

SES Rule

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.