npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@abhishekdeb/ezmailer

v0.1.1

Published

Out of the box Email wrapper for popular nodejs email systems

Downloads

13

Readme

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!

Requirements

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

Features

  • 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 ...

Installation

npm: npm i @abhishekdeb/ezmailer --save

yarn: yarn add @abhishekdeb/ezmailer

Setup

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: '[email protected]',
    pass: 'sample.password'
  }
};
  1. Require this config and pass it to ezmailer with default service
//app.js
'use strict';

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

let mailOptions = {
  from: '[email protected]',
  to: '[email protected]',
  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.
ezmailer.sendMail(mailOptions).then(
  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

Extension

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.
NOTES

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

Usage

  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.

Meta

Abhishek Deb – @vikz91[email protected]

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

https://github.com/vikz91

Contributors

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

Contributing

  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