Coder Social home page Coder Social logo

nodexpertsdev / email-it Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 7 KB

Emailit is an all-in-one package to send email effortlessly via SMTP by just providing the credentials of the host. It is responsible for setting up a valid authorisation and provides email service to your project.It handles all the cases of the sending email, be it as a normal text, as a template of any format like .hbs, .HTML, .pug or as a simple mail with attachments. It supports dynamic template rendering with provided data to be sent along.

Shell 2.28% JavaScript 95.87% HTML 1.85%

email-it's Introduction

NPM PACKAGE emailit

This will allow you to send emails using smtpTransport via nodemailer

#INSTALL

Install emailIt package to your machine using this command,

  npm i emailit

Parameters

emailit(template, fileFormat, mailDetails, templateData, callback);

  • template : Name of the template you wish to render in email;

  • fileFormat : Format of the file you are sending. eg: 'hbs', 'pug' NOTE: If the template format is html, keep the fileFormat param to hbs and also, update your actual template format. Because hbs format renders the required template and returns an html file

  • mailDetails: -recepient: (email address of the receiver), -sender: (email address of the sender), -subject: (Subject of the email),

  • templateData: (relevant template data that your templates need dynamically),

  • template : Name of the template you wish to render in email;

  • callback: A callback function;

#ENVIRONMENT VARIABLES REQUIRED

  • MAIL_USERNAME=''
  • MAIL_PASSWORD=''
  • MAIL_HOST='' gmail || mailgun || yahoo etc
  • MAIL_SERVICE='' smtp.gmail.com || smtp.yahoo.com || smtp.sendgrid.net || smtp.mailgun.com (depending upon your host)

#USE Import/require 'emailit' from newPackage Define parameter's value before calling emailIt or pass it directly in the function call

Eg:

const emailit = require('./emailit');
emailit(template, fileFormat, mailDetails, templateData, (err,res)=> {});

#EXAMPLE Refer example.js for implementation

const emailit = require('./emailit'); 

const example = function() {
  const mailDetails = {
    'recepient': '[email protected]',
    'sender': '[email protected]',
    'subject': 'Its Working'
  }
  
  const templateData = {
    name: "XYZ"
  }
  emailit(template = 'verify-email', fileFormat = 'hbs', mailDetails, templateData, (err,res)=> {
    if(err) {
      console.log('Sending email Failed');
    } else {
      console.log('Email is successfully sent.');
    }

  })
};

example();

email-it's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.