Out of the box Email wrapper for popular nodejs email systems ( NodeMailer, Sendgrid, MailGun)

Usage no npm install needed!

<script type="module">
  import abhishekdebEzmailer from 'https://cdn.skypack.dev/@abhishekdeb/ezmailer';


ezMailer v0.1.1

Out of the box Email wrapper for popular nodejs email systems ( NodeMailer, Sendgrid, MailGun)

NPM Version Build Status Downloads Stats

ezMailer is an out-of-the-box email system wrapper for node JS ecosystem. The Main principle behind ezMailer is to abstract the nuances of maintaining an (or more) email system(s) from the developer.

Oh, and it has full blown templating support as well! Yay!


  1. node >= 8
  2. npm >= 5


  • Simple and ready to use, yet Powerful Email API
  • Nodemailer, email-templates, sendgrid, Mailgun integrated
  • Examples incuded
  • Config style setup
  • Promisified API
  • Used in generator-restgoose
  • Extensible
  • Much more to come ...


npm: npm i @abhishekdeb/ezmailer --save

yarn: yarn add @abhishekdeb/ezmailer


ezMailer has fairly minimalistic config, which stays same for any email system you work with.

// config.mail.js
'use strict';

module.exports = {
  templatePath: './',
  services: {
    nodemailer: {
      provider: 'Gmail', //yahoo, etc.
      user: '[Username]@gmail.com',
      pass: '[Your_Password]'

    sendgrid: '[Your_SendGrid_Key]',

    mailgun: {
      apiKey: '[Your_Mailgun_key]',
      domain: '[Your_website_domain]'

You will feed this config to initialization of ezmailer on startup.

// app.js (or any entry point of the app)
let config = require('./config.mail.js'); // the above configuration

//Load ezmailer with the config's email section that corresponds to ezmailer
let ezmailer = require('ezmailer');
ezmailer.use(config, 'nodemailer'); //nodemailer / sendgrid / mailgun

Usage example

ezMailer needs a config file which will contain your smtp credentials for NodeMailer, sendgrid, etc...
Please use a config file like above.

  1. Create a Config File:
// config.mail.js
'use strict';

module.exports = {
  templatePath: './',

  mailer: {
    service: 'Gmail',
    user: 'sample.user@gmail.com',
    pass: 'sample.password'
  1. Require this config and pass it to ezmailer with default service
'use strict';

let ezmailer = require('ezmailer');
ezmailer.use(require('./config.mail'), 'nodemailer');
  1. Load up email options and sendMail

let mailOptions = {
  from: 'from@gmail.com',
  to: 'to@gmail.com',
  subject: 'Sample Basic ezmailer test',
  body: {
    text: 'This is basic ezmailer test. ',
    html: '<h1>This is <u>Basic</u> <b><i>ez</i>Mailer<b> test.'

//Send the mail. sendMail returns a promise.
  data => {
    console.log('Email has been sent : ', data);
  err => {
    console.log('Email could not be sent : ', err);

For more examples and usage, please refer to the (Wiki)wiki.

Release History

  • 0.1.1
    • Major Revamp of architecture
    • Upgraded all packages
    • Faster, Stronger, Sharper
  • 0.0.2
    • Small Bug FIxes
  • 0.0.1
    • Initial Release
    • Templating System Integrated


The source is pretty simple. The main index.js file is responsible for service discovery and selection. The Services are defined in 'services' directory. If you need to add a new email provider like nodemailer or sendgrid, create a new folder inside services and it will be automatically registered.
To get started with extensions, copy paste an existing service and edit through it.

  1. extension Directory name and ezmailer.use(config, <name>) should be identical.
  2. All new extensions must support the generic config file


  1. Create new entry in your email config.
  2. Copy Paste & Edit / Create new folder insideservices directory : Services/customProvider
  3. Edit/ Write index.js to first read the config file and then eventually send same reply.
  4. Write test cases for the extension in spec.js inside the same extension directory.
  5. Get reviewed by peer.


Abhishek Deb – @vikz91 – vikz91.deb@gmail.com

Distributed under the MIT license. See LICENSE for more information.



  1. VikZ91 - Base System
  2. EranGoldman - Adding Mailgun


  1. Fork it (https://github.com/yourname/yourproject/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

Bucket List

  1. Seperate Config File System
  2. Update ReadMe
  3. Seperate Npm Package (from generator-restgoose)
  4. SoC Refactoring <- going on
  5. Extensive Testing
  6. Write Test Cases using Karma
  7. Write Functions to add custom email transport
  8. Add to Travis / Circle
  9. Adding Attachments
  10. Subject Template
  11. Attachments
  12. CC, BCC
  13. Receive EMAIL Notification Hook
  14. Adding Support for MailChimp