Node.js Send an Email

Node.js Send an Email

Node.js nodemailer module is used to send an Email.

The Nodemailer module can be downloaded and installed using npm as below command.

D:\nodejs\website> npm install nodemailer

You can include above downloaded package in your application as below.

var nodemailer = require('nodemailer');

You can send email using host,port and aunthentication details like username, password as below.

Example :


var nodemailer = require('nodemailer');

        var transporter = nodemailer.createTransport({

                host: "smtp-relay.*********.com",

                port: 8888,

                auth: {

                        user: '******',

                        pass: '***********'




        var mailOptions = {

                from: 'arya*******',

                to: 'rec*****',

                subject: 'Send an email using Node Js!',

                html: 'Welcome to aryatechno tutorials!!!'



        transporter.sendMail(mailOptions, function (error, info) {

                if (error) {

                        console.log("error:" + error);

                        return false;

                } else {

                        console.log('Email sent: ' + info.response);

                        return true;





Leave a Reply

Your email address will not be published. Required fields are marked *