coming soon
When working with Jamstack or static html websites, additional functionality like sending off emails require a server or at least, SaaS.
If all you want is an endpoint that takes a few fields and sends off an email, it's a nice alternative that doesn't require the maintenance of a server.
TLDR, I wish, but no.
You can take it and build on it if you like though.
What still needs doing? Read here
Clone this repository and follow the "Get set up" guide.
-
Serverless (version ^1.27.3)
-
Node (version 8)
-
NPM
-
AWS Account (with IAM access)
You will need IAM credentials configured with AWS. You can use serverless to set these up:
serverless config credentials --provider aws --key XXXXXXX --secret XXXXXXX
If you have more than 1 set of credentials, you can create a new custom profile the Serverless way.
serverless config credentials --provider aws --key XXXXXXX --secret XXXXXXX --profile XXXXXXX
-
SMTP Email (Using a fake SMTP email for testing)
- In the serverless.yml
- Set the service name
- Change the function name to be more relevant
- Set your profile name or remove if irrelevant
If you want to get testing with SMTP fast and don't yet have your own credentials, get a fake test email using the Ethereal Email service:
SMTP_USER=someusername \
SMTP_PASS=somepassword \
SMTP_HOST=smtp.ethereal.email \
SENDER_NAME=Thomas \
SENDER_EMAIL=the@tankengine.com \
node -e 'require("./handler").email({body: "{\"email\": \"123@abc.com\", \"subject\":\"What a wonderful world\", \"content\": \"Two little birds\\r\\nCame to my doorstep\"}"}, {}, () => {})'
serverless deploy
Log into AWS
Go into the AWS Lambda panel
Go the deployed function
Add the environment variables
SENDER_EMAIL
SENDER_NAME
SMTP_HOST
SMTP_PASS
SMTP_PORT
SMTP_USER
{
"email": "you@you.com",
"subject": "Maildom",
"content": "Hi world!\n\rMaildom here"
}
- 100% Code coverage
- Send query parameters
- Use AWS Environment variables to set smtp information
- Unhappy paths especially for nicer error responses
- Dynamic variables in serverless.yml to make it multi-environment friendly and reusable across multiple projects
- An easy npm installation of the lambda service
- Optional re-captcha
- HTML Email
Here's a nice 4 minute explanation of the difference between GPL and the Lesser GPL. This library uses the Lesser GPL.
Gemma Black
Twitter: @GemmaBlackUk