Skip to content

Instantly share code, notes, and snippets.

@luetkemj
Last active January 16, 2019 22:39
Show Gist options
  • Save luetkemj/bda705a62b0534d9a10b2eba4efa01c3 to your computer and use it in GitHub Desktop.
Save luetkemj/bda705a62b0534d9a10b2eba4efa01c3 to your computer and use it in GitHub Desktop.
Nodemailer quick setup for gmail
const nodemailer = require('nodemailer');
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
type: 'OAuth2',
user: 'example@gmail.com',
clientId: 'XXX',
clientSecret: 'XXX',
refreshToken: 'XXX'
},
});
const mailOptions = {
from: 'My Name <example@gmail.com>',
to: 'test@gmail.com',
subject: 'Hello!',
text: 'Hello World!!'
}
transporter.sendMail(mailOptions, function (err, res) {
if(err){
console.log('Error');
} else {
console.log('Email Sent');
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment