I\'ve set up a basic NodeJS server (using the nodemailer module) locally (http://localhost:8080
) just so that I can test whether the server can actually send ou
For those who actually want to use OAuth2 / don't want to make the app "less secure", you can achieve this by
SCOPES
var from ['https://www.googleapis.com/auth/gmail.readonly']
to ['https://mail.google.com/']
in the quickstart js file provided as suggested in troubleshooting at https://nodemailer.com/smtp/oauth2/acessToken
, refreshToken
, and expires
attributes needed in the OAuth2 Examples for NodemailerThis way you can use OAuth2 authentication like the following
let transporter = nodemailer.createTransport({
service: 'Gmail',
auth: {
type: 'OAuth2',
user: 'user@example.com',
clientId: '000000000000-xxx0.apps.googleusercontent.com',
clientSecret: 'XxxxxXXxX0xxxxxxxx0XXxX0',
refreshToken: '1/XXxXxsss-xxxXXXXXxXxx0XXXxxXXx0x00xxx',
accessToken: 'ya29.Xx_XX0xxxxx-xX0X0XxXXxXxXXXxX0x',
expires: 1484314697598
}
});
instead of storing your gmail password in plaintext and downgrading the security on your account.