Easily send email using any major email service provider like AWS SES, SendGrid or Gmail
It uses Nodemailer to send email. They've support for several well-known providers
npm install send-email
SEND_EMAIL_SERVICE_PROVIDER=SES-US-EAST-1
SEND_EMAIL_AUTH_USER=AKIAJLQWEFTYNLFGRQDIG
SEND_EMAIL_AUTH_PASS=Arfk/T8SgGvCtY7Rdq7VOsdjhjDHHOD4F8p36HEWhZl
const sendEmail = require('send-email')
let payload = {
"to": "test@email.com",
"subject": "sending emails using send-email",
// "text": "hello world!",
"html": "hello <b>world</b>!",
"from": "Myself <myself@domain.com>"
}
sendEmail(payload)
.then((res) => {
console.log(res);
})
If you are using dotenv to set environment variables dynamically then you need to call require('dotenv').config()
before importing send-email.
const dotenv = require('dotenv');
dotenv.config();
const sendEmail = require('send-email')
Since we are using SMTP protocol its little bit slower than using service provider API
- Credentials in Environment variables & check it
- SES API ?
- Handle Errors properly.
MIT © Ashik Nesin