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

ez-email

v1.0.9

Published

ez-email is a package built to get fast email functionality in your node application

Downloads

31

Readme

ez-email

ez-email is a fast, easy, basic emailing package built off of nodemailer. This is to get you off and running with little code.


Getting Started

Download the Example repo

Copy and paste these commands in your terminal, make sure to put in your email credientials first!

git clone https://github.com/shiratap/example-ez-email
cd example-ez-email
npm i
code .env index.js .
node index.js

NPM Installation into an existing node app:

npm i ez-email

In your javascript file:

const EZE = require('ez-email');

Simple example with ez-email:

Result:

Recommended: Use a .env file for email credentials

ez-email function runs the dotenv method to map out .env variables, so you don't need to invoke the dotenv function

EMAIL={your-email-in-raw-text-here}
PASSWORD={your-password-in-raw-text-here}
SERVICE={List is linked below} //Defaulted to gmail

Service list

Gmail users: Disabling "Less Secure App Access"

Route in your browser to https://myaccount.google.com/lesssecureapps, and enable less secure apps


Function Parameters

EZE(recipients, message, emailCredentials);

recipients

Represents the list of recipients you want to send to. Format your array as such:

const plain = ['[email protected]'];
const withoutNames = [{ email: '[email protected]' }];
const withNames = [{ name: 'A dude', email: '[email protected]' }];

As you can see, you have the option to have the raw email string or to use an object. You can tag on other properties to the object if you wish to go that route, they'll be disregarded when running in the EZE function. The name property is used in the greeting line, which will be talked about in the message section.

message

This is your message object. Your email properties are defined here.

const maxProperties = {
  greeting: 'Hello',
  subject: 'This is a test',
  messageType: 'html', //The type of markup your message is. Options here are ['html', 'text'] with text as the default
  message: '<h2>We made it!</h2>'
};
const minimalProperties = {
  message: 'Hello' //Technically you don't even need this either, but I doubt you want to be sending emails without messages
};

The value in greeting: is what would come at the top of the message accompanied with the recipient name (if it exists in your recipient's object) or email string (if it doesn't).

Other than that, the properties here are pretty self explanatory. Though none of these properties are actually required to send emails, you wouldn't be sending an email in the first place if you had no message to the recipient (I hope).

emailCredentials

const emailCredentials = {
  email: '[email protected]',
  password: 'rawtext',
  service: 'yourserviceproviderhere'
};

You might be asking what is the point of this feature if ez-email already parses your .env file, and the answer to that is if you have multiple emails that you're sending from. Service defaults to 'gmail' if none is provided. Nodemailer will give you an error if your credentials aren't correct.


Examples with FS

With an html template

Future Updates

  • Greeting customization for html
  • Placeholder feature in messages
  • Optimization
  • Testing

Was very shocked and happy to see the amount of weekly downloads at 361 in 2 days! Would love to contribute more features to help you guys out. Please add in issues to the github repo if you would like to see new ideas in place, or Email Me.