Sign inSign up

chinchalinchin/lambda-forward-email

By chinchalinchin

•Updated over 4 years ago

AWS Lambda function that hooks into an SES Receipt Rule and forwards emails to an external address.

Image
0

315

chinchalinchin/lambda-forward-email repository overview

⁠Email Forwarding Lambda

If you have AWS SES setup to deliver mail to an S3 bucket, you can use this image to setup an email forwarding scheme to forward emails in the bucket to an external address. First, deploy this image to an AWS Lambda function,

aws lambda create-function --function name <name> \
                                                    --role <role>
                                                    --code docker.io/chinchalinchin/lambda-forward-email:latest

Lambda's assumed role passed in through the previous command's --role argument will require the following IAM permissions,

{
    "Sid": "SESPermissions",
    "Effect": "Allow",
    "Action": [ 
          "ses:SendEmail",
          "ses:SendRawEmail",
           "s3:GetObject"
      ],
     "Resource": [
            "arn:aws:s3:::<email-bucket>/*
             "arn:aws:ses:<region>:<account-id>:identity/*
     ]
}

The Lambda will require the following variables delivered to its environment:

  1. MailS3Bucket: This is the name of the bucket where SES is delivering mail. This is the same bucket that Lambda must be given permission to access in the policy quoted above.
  2. MailS3Prefix: This is the folder within the bucket where the mail is stored.
  3. MailSender: This is the address from where the forwarded email is sent.
  4. MailRecipient: This is the address to where the forwarded email is sent.
  5. Region: This is the AWS region where resources are located.

After the Lambda is deployed and configured, you will need to add the function to the list of SES receipt rule actions. Refer to official documentation⁠ for more information on setting up a Lambda SES receipt rule.

Tag summary

Content type

Image

Digest

Size

186.9 MB

Last updated

over 4 years ago

docker pull chinchalinchin/lambda-forward-email