This is an AWS Lambda function to forward mails from SES to Slack, based on the Serverless framework.
Mail Server
↓ SMTP
AWS SES
↓ Publish
AWS SNS
↓ Subscribe
AWS Lambda
↓ HTTP(S)
Slack Incoming Webhook
Deploy a Lambda function.
# Setup credentials
npm run serverless -- config credentials -p aws -k IAM_KEY -s IAM_SECRET
# Deploy
npm install
npm run deploy
Open the AWS Management Console and do following steps:
- Open Lambda and Check ARN of the function, like
arn:aws:lambda:ap-northeast-1:***:function:ses-to-slack-dev-handle
. - Add an environment variable on the function:
WEBHOOK
: URL of Slack Incoming Webhook (Mandatory)WEBHOOK_USERNAME
: Username for Incoming Webhook request (Optional)WEBHOOK_ICON_EMOJI
: Icon for Incoming Webhook request (Optional)WEBHOOK_HOST_HEADER
: Host header for Incoming Webhook request (Optional)
- Open SNS and create a topic.
- Create a subscription on the topic:
- Protocol: AWS Lambda.
- Endpoint: ARN of the Lambda function.
- Open SES and make sure your domain has been verified.
- Create a rule set with the following action:
- SNS topic: ARN of the SNS topic.
- Encoding: UTF-8
Mattermost is a Slack alternative. You can send mails to a Mattermost channel as well.
- Create an Incoming Webhook on a Mattermost team.
- Set the
WEBHOOK
environment variable.
If the instance is protected by the security group, you can send mails via VPC. For example,
Mail Server
↓ SMTP
AWS SES
↓ Publish
AWS SNS
↓ Subscribe
AWS Lambda
↓ ENI
↓ VPC
↓ ENI
AWS EC2
If a reverse proxy exists and requires Host
header, you can specify the WEBHOOK_HOST_HEADER
environment variable.
SNS can receive mails that are 150kB or less. Larger mails will bounce.
Feel free to open an issue or pull request.