Last active
December 10, 2016 09:28
-
-
Save PandaWhoCodes/4bce68c3e5950916320b5bbcca0cf6b8 to your computer and use it in GitHub Desktop.
Send mail using Gmail in node.js using nodemailer
This file contains hidden or 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
'use strict'; | |
var nodemailer = require('nodemailer'); | |
//configure nodemailer | |
// visit: https://nodemailer.com/ | |
// For other types of transports (Amazon SES, Sendgrid,mailchimp...) see https://nodemailer.com/2-0-0-beta/setup-transporter/ | |
var mailTransport = nodemailer.createTransport('smtps://<user>%40gmail.com:<password>@smtp.gmail.com'); | |
function senEmail(email) { | |
var mailOptions = { | |
from: '"Ashish Cherian" <[email protected]>', | |
to: email, // Email is variable that stores the email address | |
subject: 'Node Js stuff', | |
text: 'What ever text you want to make in the email. Or insert an ' | |
}; | |
return mailTransport.sendMail(mailOptions).then(function() { | |
console.log('New star email notification sent to: ' + email); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment