Guest User

Untitled

a guest
Jan 6th, 2018
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. const nodemailer = require('nodemailer');
  2. const xoauth2 = require('xoauth2');
  3.  
  4. // create reusable transporter object using the default SMTP transport
  5. let transporter = nodemailer.createTransport( {
  6. service: 'gmail',
  7. xoauth2: xoauth2.createXOAuth2Generator({
  8. user: 'me@myDomain.com',
  9. clientid: 'blahblahblah.apps.googleusercontent.com',
  10. clientSecret: 'k33p-gUeSsINg',
  11. refreshToken: '123BritneyIsTheBest'
  12. }),
  13. tls: {
  14. rejectUnauthorized: false
  15. }
  16. } );
  17.  
  18. // setup email data with unicode symbols
  19. let mailOptions = {
  20. from: 'me@myDomain.com',
  21. to: 'me@yahoo.com',
  22. subject: 'Hello there Google API...',
  23. text: 'Hello Google API',
  24. html: '<b>Hello Google API</b>'
  25. };
  26.  
  27. // send mail with defined transport object
  28. transporter.sendMail(mailOptions, (error, info) => {
  29. if (error) {
  30. return console.log(error);
  31. }
  32. console.log('Message sent: ', info.messageId);
  33. });
  34.  
  35. {
  36. 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
  37. at SMTPConnection._formatError (C:abcindex.js:591:19)
  38. at SMTPConnection._actionMAIL (C:abcindex.js:1350:34)
  39. at SMTPConnection._responseActions.push.str (C:abcindex.js:840:18)
  40. at SMTPConnection._processResponse (C:abcindex.js:747:20)
  41. at SMTPConnection._onData (C:abcindex.js:543:14)
  42. at TLSSocket._socket.on.chunk (C:abcindex.js:495:47)
  43. at emitOne (events.js:116:13)
  44. at TLSSocket.emit (events.js:211:7)
  45. at addChunk (_stream_readable.js:263:12)
  46. at readableAddChunk (_stream_readable.js:250:11)
  47. code: 'EENVELOPE',
  48. response: '530-5.5.1 Authentication Required. Learn more atn530 5.5.1 https://support.google.com/mail/?p=WantAuthError l24sm4075119ywk.21 - gsmtp',
  49. responseCode: 530,
  50. command: 'MAIL FROM'
  51. }
  52.  
  53. const nodemailer = require('nodemailer');
  54.  
  55. // create reusable transporter object using the default SMTP transport
  56. let transporter = nodemailer.createTransport( {
  57. host: 'smtp.gmail.com',
  58. port: 587,
  59. secure: false,
  60. auth: {
  61. user: 'me@myDomain.com',
  62. pass: 'Seriously?'
  63. }
  64. });
  65.  
  66. ... all the rest is the same, removed for brevity...
Add Comment
Please, Sign In to add comment