Created
April 3, 2019 18:00
-
-
Save jibin2706/e711f6073b11d8b8b7f63bf8888e6edc to your computer and use it in GitHub Desktop.
Sending email using nodemailer with gmail account
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment