Skip to content

Instantly share code, notes, and snippets.

@sagardere
Created May 22, 2018 16:26
Show Gist options
  • Save sagardere/ee6e1a0a3cebbc3fc5405949ce2b305a to your computer and use it in GitHub Desktop.
Save sagardere/ee6e1a0a3cebbc3fc5405949ce2b305a to your computer and use it in GitHub Desktop.
var nodemailer = require('nodemailer');
//send mail using nodemailer via gmail service
var transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: 'yourEmail',
pass: 'yourPassword'
}
});
var mailOptions = {
from: 'mail Id of From',
to: 'mail Id to To',
subject: 'Sending Email using Node.js',
text: 'That was easy!',
text: 'Hello world?', // plain text body
html: '<b>Hello world?</b>'
};
transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment