Netlify lambda function that is able to send emails.
It uses https://www.mailjet.com/
as an SMTP provider and sends emails from [email protected]
. The limit is set to 200/day by SMTP provider.
During testing or development it's a good idea to use service like mailtrap.io
that will allow you to avoid spaming an actual email address. It require an account and proper configuration in .env file as normal SMTP provider.
- Clone repository
cd
into repo directory- Create
.env
file in root directory and add there:- EMAIL_CLIENT_HOST = ...
- EMAIL_CLIENT_PORT = ...
- EMAIL_CLIENT_USER = ...
- EMAIL_CLIENT_PASS = ...
- EMAIL_FROM = ...
- Run
npm ci
- Run
npm run lambda-serve
- Serverless function will start on localhost:9000/sendEmail
Required fields - to
, subject
, msg
.
to
field must be a valid email address.
POST /sendEmail HTTP/1.1
Host: localhost
Content-Type: application/json
Content-Length: 103
{
"to": "[email protected]",
"subject": "Test subject",
"msg":"Test content"
}
https://mystifying-mahavira-9a87b3.netlify.app/.netlify/functions/sendEmail