Last active
March 24, 2019 21:01
-
-
Save adamelliotfields/5afbc4503319e4ff03d38e74d90750d5 to your computer and use it in GitHub Desktop.
Nodemailer v0.7 Gmail Example
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
const nodemailer = require('nodemailer'); | |
const transport = nodemailer.createTransport('smtp', { | |
auth: { | |
user: process.env.GMAIL_USER, | |
pass: process.env.GMAIL_PASS, | |
}, | |
}); | |
transport.sendMail({ | |
from: process.env.GMAIL_USER, | |
to: process.env.GMAIL_USER, | |
generateTextFromHTML: true, | |
encoding: 'base64', | |
subject: 'Hello world', | |
html: '<b>Hello world</b>', | |
}, (err) => { | |
if (err) { | |
console.error('Error:', err.message); | |
} | |
transport.close(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ghost uses Nodemailer v0.7, so this is a quick smoke test to check settings.
You need to enable 2-Step Verification and then create an App Password.
If
auth.user
includes@gmail.com
, then Nodemailer will setservice
,host
,port
, andsecureConnection
automatically.Usage: