Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const nodemailer = require('nodemailer');
- const xoauth2 = require('xoauth2');
- // create reusable transporter object using the default SMTP transport
- let transporter = nodemailer.createTransport( {
- service: 'gmail',
- xoauth2: xoauth2.createXOAuth2Generator({
- user: 'me@myDomain.com',
- clientid: 'blahblahblah.apps.googleusercontent.com',
- clientSecret: 'k33p-gUeSsINg',
- refreshToken: '123BritneyIsTheBest'
- }),
- tls: {
- rejectUnauthorized: false
- }
- } );
- // setup email data with unicode symbols
- let mailOptions = {
- from: 'me@myDomain.com',
- to: 'me@yahoo.com',
- subject: 'Hello there Google API...',
- text: 'Hello Google API',
- html: '<b>Hello Google API</b>'
- };
- // send mail with defined transport object
- transporter.sendMail(mailOptions, (error, info) => {
- if (error) {
- return console.log(error);
- }
- console.log('Message sent: ', info.messageId);
- });
- {
- Error: Mail command failed: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 https://support.google.com/mail/?p=WantAuthError l24sm4075119ywk.21 - gsmtp
- at SMTPConnection._formatError (C:abcindex.js:591:19)
- at SMTPConnection._actionMAIL (C:abcindex.js:1350:34)
- at SMTPConnection._responseActions.push.str (C:abcindex.js:840:18)
- at SMTPConnection._processResponse (C:abcindex.js:747:20)
- at SMTPConnection._onData (C:abcindex.js:543:14)
- at TLSSocket._socket.on.chunk (C:abcindex.js:495:47)
- at emitOne (events.js:116:13)
- at TLSSocket.emit (events.js:211:7)
- at addChunk (_stream_readable.js:263:12)
- at readableAddChunk (_stream_readable.js:250:11)
- code: 'EENVELOPE',
- response: '530-5.5.1 Authentication Required. Learn more atn530 5.5.1 https://support.google.com/mail/?p=WantAuthError l24sm4075119ywk.21 - gsmtp',
- responseCode: 530,
- command: 'MAIL FROM'
- }
- const nodemailer = require('nodemailer');
- // create reusable transporter object using the default SMTP transport
- let transporter = nodemailer.createTransport( {
- host: 'smtp.gmail.com',
- port: 587,
- secure: false,
- auth: {
- user: 'me@myDomain.com',
- pass: 'Seriously?'
- }
- });
- ... all the rest is the same, removed for brevity...
Add Comment
Please, Sign In to add comment