Skip to content

Instantly share code, notes, and snippets.

@luetkemj luetkemj/node-mailer.js
Last active Jan 16, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.