A
A
Alexander2021-07-30 01:55:33
Node.js
Alexander, 2021-07-30 01:55:33

Error when sending email to nodemailer, gmail?

Tell me why this error appears when trying to send a message with nodejs?

'534-5.7.14  Learn more at\n' +
    '534 5.7.14  https://support.google.com/mail/answer/78754 d7sm1868963qth.70 - gsmtp',
  responseCode: 534,
  command: 'AUTH PLAIN'
}
2021-07-29T22:52:33.905Z	86eef5db-c86c-44e7-8f39-de3f74f417ae	ERROR	Unhandled Promise Rejection 	{"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"Error: Invalid login: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbu\n534-5.7.14 va-73oYnId42dUGqykJLJKgdOuQvhV9UDHvWAcmdt6dbP0Mn4g4QR5Gr3XtVdBdGKPTh4\n534-5.7.14 A1KRuNYwd0SXW9ViAyaJzoEUe37DyuBgd31I5J-YO6_NQD7sKmkYJJ4lg1i8s4wB>\n534-5.7.14 Please log in via your web browser and then try again.\n534-5.7.14  Learn more at\n534 5.7.14  https://support.google.com/mail/answer/78754 d7sm1868963qth.70 - gsmtp","reason":{"errorType":"Error","errorMessage":"Invalid login: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbu\n534-5.7.14 va-73oYnId42dUGqykJLJKgdOuQvhV9UDHvWAcmdt6dbP0Mn4g4QR5Gr3XtVdBdGKPTh4\n534-5.7.14 A1KRuNYwd0SXW9ViAyaJzoEUe37DyuBgd31I5J-YO6_NQD7sKmkYJJ4lg1i8s4wB>\n534-5.7.14 Please log in via your web browser and then try again.\n534-5.7.14  Learn more at\n534 5.7.14  https://support.google.com/mail/answer/78754 d7sm1868963qth.70 - gsmtp","code":"EAUTH","response":"534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbu\n534-5.7.14 va-73oYnId42dUGqykJLJKgdOuQvhV9UDHvWAcmdt6dbP0Mn4g4QR5Gr3XtVdBdGKPTh4\n534-5.7.14 A1KRuNYwd0SXW9ViAyaJzoEUe37DyuBgd31I5J-YO6_NQD7sKmkYJJ4lg1i8s4wB>\n534-5.7.14 Please log in via your web browser and then try again.\n534-5.7.14  Learn more at\n534 5.7.14  https://support.google.com/mail/answer/78754 d7sm1868963qth.70 - gsmtp","responseCode":534,"command":"AUTH PLAIN","stack":["Error: Invalid login: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbu","534-5.7.14 va-73oYnId42dUGqykJLJKgdOuQvhV9UDHvWAcmdt6dbP0Mn4g4QR5Gr3XtVdBdGKPTh4","534-5.7.14 A1KRuNYwd0SXW9ViAyaJzoEUe37DyuBgd31I5J-YO6_NQD7sKmkYJJ4lg1i8s4wB>","534-5.7.14 Please log in via your web browser and then try again.","534-5.7.14  Learn more at","534 5.7.14  https://support.google.com/mail/answer/78754 d7sm1868963qth.70 - gsmtp","    at SMTPConnection._formatError (/var/task/node_modules/nodemailer/lib/smtp-connection/index.js:784:19)","    at SMTPConnection._actionAUTHComplete (/var/task/node_modules/nodemailer/lib/smtp-connection/index.js:1536:34)","    at SMTPConnection.<anonymous> (/var/task/node_modules/nodemailer/lib/smtp-connection/index.js:540:26)","    at SMTPConnection._processResponse (/var/task/node_modules/nodemailer/lib/smtp-connection/index.js:947:20)","    at SMTPConnection._onData (/var/task/node_modules/nodemailer/lib/smtp-connection/index.js:749:14)","    at TLSSocket.SMTPConnection._onSocketData (/var/task/node_modules/nodemailer/lib/smtp-connection/index.js:189:44)","    at TLSSocket.emit (events.js:375:28)","    at addChunk (internal/streams/readable.js:290:12)","    at readableAddChunk (internal/streams/readable.js:265:9)","    at TLSSocket.Readable.push (internal/streams/readable.js:204:10)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: Error: Invalid login: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbu","534-5.7.14 va-73oYnId42dUGqykJLJKgdOuQvhV9UDHvWAcmdt6dbP0Mn4g4QR5Gr3XtVdBdGKPTh4","534-5.7.14 A1KRuNYwd0SXW9ViAyaJzoEUe37DyuBgd31I5J-YO6_NQD7sKmkYJJ4lg1i8s4wB>","534-5.7.14 Please log in via your web browser and then try again.","534-5.7.14  Learn more at","534 5.7.14  https://support.google.com/mail/answer/78754 d7sm1868963qth.70 - gsmtp","    at process.<anonymous> (/var/runtime/index.js:35:15)","    at process.emit (events.js:387:35)","    at processPromiseRejections (internal/process/promises.js:245:33)","    at processTicksAndRejections (internal/process/task_queues.js:96:32)"]}
Unknown application error occurred


My code
function sendEmail(message: SendEmailProps) {
  return new Promise((res, rej) => {
    const transporter = nodemailer.createTransport({
      service: 'gmail',
      auth: {
        user: 'q****@gmail.com',
        pass: '*****',
      },
    })
    transporter.sendMail(message, function (err, info) {
      if (err) {
        console.log(err)
        rej(err)
      } else {
        console.log(info)
        res(info)
      }
    })
  })
}


Everything works on locallhost

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Prog Spectar, 2021-07-30
@progspectar

It's hard to say without seeing the code, but for example, you can try changing the settings in google-accounte:
https://edigleyssonsilva.medium.com/how-to-send-em...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question