Skip to content

Instantly share code, notes, and snippets.

@djom202
Created May 5, 2017 19:39
Show Gist options
  • Save djom202/76d5981bf9d651d1114ddb06717acb69 to your computer and use it in GitHub Desktop.
Save djom202/76d5981bf9d651d1114ddb06717acb69 to your computer and use it in GitHub Desktop.
Sending an email with Nodejs
var nodemailer = require('nodemailer');
exports.send = function(){
var mailTransport = nodemailer.createTransport('smtps://user%40gmail.com:pass$@smtp.gmail.com'),
email = 'user@gmail.com',
mailOptions = {
from: '"Firebase Database Quickstart" <noreply@firebase.com>',
to: email,
subject: 'New star!',
text: 'One of your posts has received a new star!'
};
return mailTransport.sendMail(mailOptions).then(function() {
console.log('New star email notification sent to: ' + email);
}).catch(function(error) {
console.log('Failed to send weekly top posts email:', error);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment