Skip to content

Easily send email using any major email service provider like AWS SES, SendGrid or Gmail

Notifications You must be signed in to change notification settings

AshikNesin/send-email

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

send-email

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

Install

npm install send-email

Environment Variables

SEND_EMAIL_SERVICE_PROVIDER=SES-US-EAST-1
SEND_EMAIL_AUTH_USER=AKIAJLQWEFTYNLFGRQDIG
SEND_EMAIL_AUTH_PASS=Arfk/T8SgGvCtY7Rdq7VOsdjhjDHHOD4F8p36HEWhZl

Usage

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);
    })

Note

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

Todo

  • Credentials in Environment variables & check it
  • SES API ?
  • Handle Errors properly.

Inspiration

Now Emails

License

MIT © Ashik Nesin