NODE JS

How send E-Mail in NODE JS || simplest way to send mail in node

  • Neel Bhardwaj

  • 15-Jan-2022

  • 0 comments

  • 134

For play with email sytem in NODE JS. Firstly you install the nodemailer module.

STEP 1 :

npm i nodemailer

 

STEP 2 :

var nodemailer = require('nodemailer');

var transport = nodemailer.createTransport({

   host:'smtp.gmail.com',

   port:587,

   secure:false,

   requireTLS:true,

   auth:{

     user : 'test@gmail.com',

     pass : '';

  }

});

var mailOption = {

   from : 'test@gmail.com',

   to: 'xyz@gmail.com',

   subject:'this is subject',

   text:'This is the text send in mail'

}

transport.sendMail(mailOption,function(error,info){

   if(error){

      console.log(error);

   }else{

      console.log('Email send',info.response);

 }

});

"Programming isn't about what you know,
it's about what you can figure out.”
Chris Pine

Neel Bhardwaj

A full stack developer. I have a Passion for Creating Clean, Beautiful, Interactive, Minimalistic, Responsive and User Friendly website, Developed by Modular, Scalable and Functional Code.

Recent comments

Leave a reply