var nodemailer = require('nodemailer');
var smtpTransport = require('nodemailer-smtp-transport');
var transporter = nodemailer.createTransport(smtpTransport({
service: 'gmail',
host: 'smtp.gmail.com',
auth: {
user: 'somerealemail@gmail.com',
pass: 'realpasswordforaboveaccount'
}
}));
var mailOptions = {
from: 'somerealemail@gmail.com',
to: 'friendsgmailacc@gmail.com',
subject: 'Sending Email using Node.js[nodemailer]',
text: 'That was easy!'
};
transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});
// There are more things to do according to the nodemailer documentation
// https://community.nodemailer.com/using-gmail/