https://github.com/traviswimer/serverless-respat-ses-forwarder
Resource pattern to setup email forwarding through SES
https://github.com/traviswimer/serverless-respat-ses-forwarder
Last synced: about 1 year ago
JSON representation
Resource pattern to setup email forwarding through SES
- Host: GitHub
- URL: https://github.com/traviswimer/serverless-respat-ses-forwarder
- Owner: traviswimer
- License: mit
- Created: 2018-07-19T17:19:50.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-26T19:33:23.000Z (almost 8 years ago)
- Last Synced: 2025-02-17T10:49:05.167Z (over 1 year ago)
- Language: JavaScript
- Size: 69.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# serverless-respat-ses-forwarder
> Resource Pattern for forwarding emails using SES
## Usage
This package is intended for use with the **serverless-respat plugin**. ([install/usage info](https://github.com/traviswimer/serverless-respat)).
Install:
`npm install --save-dev serverless-respat-ses-forwarder`
Add patterns to the "custom" object in your serverless config file:
```javascript
"custom": {
"serverless-respat": {
prefix: "${self:service}-${opt:stage}",
patterns: [
{
pattern: require("serverless-respat-ses-forwarder"),
config: {
ses_ruleset_name: "EmailForwarding",
bucket_name: "el-bucket-de-email",
email_recipients: ["kjsdfjweijfkjsdfhjkhdf.com"],
lambda_function_name: "ForwardEmail"
}
}
]
}
}
```
Add a function that does the email forwarding for you. The property name should match the `lambda_function_name` in your plugin config.
```javascript
"functions": {
"forwardEmail": {
"handler": "handlers.forwardEmail",
"role": "SesForwarderLambdaForwardRole"
}
}
```
The easiest way to setup a forwarding lambda function is to use [aws-lambda-ses-forwarder](https://github.com/arithmetric/aws-lambda-ses-forwarder). Your `handlers.js` file would then look something like this:
```javascript
const ses_forwarder = require('aws-lambda-ses-forwarder');
module.exports = {
forwardEmail: (event, context, callback) => {
return ses_forwarder.handler(event, context, callback, {
config: {
fromEmail: "noreply@YOUR_DOMAIN",
subjectPrefix: "YOUR_DOMAIN: ",
emailBucket: "YOUR_DOMAIN-email",
emailKeyPrefix: "",
forwardMapping: {
"@YOUR_DOMAIN": ["YOUR_USERNAME@gmail.com"]
}
}
})
}
}
```
Make sure you have verified your email address and domains for SES using the AWS console.
## Config options
**pattern_name** - (string, _default: "SesForwarder"_) A pattern name included in resource names.
**bucket_path** - (string, _default: '/'_) Path to bucket.
**bucket_name** - (string, REQUIRED) The S3 bucket name used to store your emails.
**ses_ruleset_name** - (string, REQUIRED) The active SES ruleset where the receipt rules will be added. The ruleset must already exist.
**email_recipients** - (string, REQUIRED) The email address where you would like the emails to be forwarded.
**lambda_function_name** - (string, REQUIRED) The name of the lambda function that does the forwarding.