https://github.com/proprietary/ses-incoming-mail-forwarder
AWS lambda function to forward inbound emails to SES to another email
https://github.com/proprietary/ses-incoming-mail-forwarder
Last synced: 10 months ago
JSON representation
AWS lambda function to forward inbound emails to SES to another email
- Host: GitHub
- URL: https://github.com/proprietary/ses-incoming-mail-forwarder
- Owner: proprietary
- License: apache-2.0
- Created: 2024-09-07T21:56:25.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-08T04:09:02.000Z (almost 2 years ago)
- Last Synced: 2025-04-04T22:45:38.706Z (about 1 year ago)
- Language: Go
- Size: 28.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
This helped me receive mail on a domain that I did not have a real
IMAP mail server for. I was using it just for sending mail with AWS
SES. But I also wanted to receive emails if someone replied to a sent
email.
First follow the instructions in AWS's documentation on
[setting up email receiving](https://docs.aws.amazon.com/ses/latest/dg/receiving-email-mx-record.html). Make sure to add the MX record on your domain:
```
10 inbound-smtp..amazonaws.com
```
Then in the AWS SES console, I created a new email receiving rule on
the domain with the action "Deliver to Amazon S3 bucket". Create a new
bucket. All incoming emails will be dropped in that bucket. We can use
the PutObject events to trigger this Lambda.
# Usage
## 1. Create a new IAM policy
Make it allow `s3:GetObject` and `ses:SendRawEmail`.
Example (change ``, ``, ``):
```json
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"logs:CreateLogStream",
"logs:CreateLogGroup",
"logs:PutLogEvents"
],
"Resource": "*"
},
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": [
"s3:GetObject",
"ses:SendRawEmail"
],
"Resource": [
"arn:aws:s3:::/*",
"arn:aws:ses:::identity/*"
]
}
]
}
```
## 2. Create lambda function and configure environment variables
`FORWARD_TO_ADDRESS`: the email address you want to forward incoming mail to
## 3. Build this code
```
make bootstrap
```
(Prerequisites: Install [Go](https://go.dev/))
You should see `lambda.zip` in the directory. Upload the ZIP to AWS Lambda an deploy the Lambda.
## 3. Add a trigger for the Lambda
Set the trigger to Put events on the S3 bucket that SES puts incoming emails in.
# TODO
- [ ] automation with CloudFormation and/or Terraform