In this video we are going to learn about Send Email using Gmail.
Lets see how can we send an email.
Here I am going to use nodemailer module for sending the email.
Nodemailer is the Node.js npm module that allows to send email easily.
So first off all install nodemailer module.
So go to the command prompt run the command.


npm install nodemailer


Now go to the index.js file.
Here require the nodemailer so just write here.


const nodemailer = require('nodemailer');


Now just call the createTrasport method and inside this method pass the service and auth.


var transporter = nodemailer.createTransport({
service:'gmail',
auth:{
user:\"yourgmailid@gmail.com\",
pass:\"yourpassword\".
}
});


Now set the mail options.


var mailOptions = {
from:'testmail@gmail.com',
to:'testmail@gmail.com',
subject:'NodeJs Test Mail',
text:'This is test mail from node js application'.
};



Now call the send mail method.


transporter.sendMail(mailOptions,function(err,info){
if(err)
{
console.log(err);
}
else{
console.log('Email Sent:' + info.response);
}
});


Alright now goto your gmail and click on account.
Then click security now turn on the less secure app access.
Now you lets check.
So goto the command prompt and run the index.js.


node index.js


Ok mail sent.
Now go to the gmail and here you can see the mail.
So in this way you can Send Email using Gmail.