Send Mail in Node Js

node js
npm module

Node mailer used to send emails to the user, this node mailer available in node modules.

npm install nodemailer --save

In short, what you need to do to send messages, would be the following:

  • Create a Nodemailer transporter using either SMTP or some other transport mechanism
  • Set up message options (who sends what to whom)
  • Deliver the message object using the sendMail() method of your previously created transporter

This is a complete example to send an email with plain text and HTML body

'use strict';
const nodemailer = require('nodemailer');

// create reusable transporter object using the default SMTP transport
let transporter = nodemailer.createTransport({
    service: 'gmail',
    auth: {
        user: '',
        pass: 'yourpass'

// setup email data with unicode symbols
let mailOptions = {
    from: '"Abc Xyz" <>', // sender address
    to: ',', // list of receivers
    subject: 'Hello Subject', // Subject line
    text: 'Hello world Body?', // plain text body
    html: '<b>Hello world ?</b>' // html body

// send mail with defined transport object
transporter.sendMail(mailOptions, (error, info) => {
    if (error) {
        return console.log(error);
    console.log('Message %s sent: %s', info.messageId, info.response);



You might also like:

Use java script file client side and server side at a time in node js

30-07-2017 node js include call javascript

How to get id by using name attribute in javascript

20-03-2017 html id name javascript

Get previous date from given date in javascript

06-03-2017 date javascript previous date

Change datepicker display format

06-03-2017 datepicker angular js

Sample Validations in javascript

22-02-2017 validations javascript