rest-email-api
Welcome to rest-email-api! Now sending emails is as easy as sending an HTTP request.
This email API supports sending templated emails and non-templated emails through a POST body.
Great for sending password reset emails to users, account validation emails, or MFA confirmation emails.
Installation
npm install rest-email-api
Here's an example!
Step One: Start the server like so:
// index.jsconst emailService = const path = emailService
Step Two: Set up a folder to store the templates.
For this example, let's set up a "congrats" template to congratulate our recipient for a recent purchase.
.├── index.js└── templates └── congrats ├── html.pug
html.pug
p Congratulations! Enjoy the purchase of your new:
p #{itemId}
Step Three: Send your HTTP request!
Below is an example documented via Postman.
For a templated email:
- The request header should have your authorization secret key.
- Set the template folder name that the service should use.
- Then, your POST body should look something like this:
- And finally, your recipient can enjoy their new email.
For an ad-hoc/on the fly email made without a template:
- The request header should have your authorization secret key.
- The only thing left to do is to set your POST body like so:
- And then in your inbox is a shiny new email.