Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

242
Visualizações
making nodemailer send emails with different gmail accounts

i authenticate with passportjs with success but nodemailer only send emails with one email which is the one used in the console.cloud.google.

wheni try other gmail accounts, i get this error:

Error: Invalid login: 535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/?p=BadCredentials u6sm13346885wrp.0 - gsmtp at SMTPConnection._formatError (/var/www/html/Recrute/node_modules/nodemailer/lib/smtp-connection/index.js:784:19) at SMTPConnection._actionAUTHComplete (/var/www/html/Recrute/node_modules/nodemailer/lib/smtp-connection/index.js:1536:34) at SMTPConnection. (/var/www/html/Recrute/node_modules/nodemailer/lib/smtp-connection/index.js:1515:26) at SMTPConnection._processResponse (/var/www/html/Recrute/node_modules/nodemailer/lib/smtp-connection/index.js:947:20) at SMTPConnection._onData (/var/www/html/Recrute/node_modules/nodemailer/lib/smtp-connection/index.js:749:14) at TLSSocket.SMTPConnection._onSocketData (/var/www/html/Recrute/node_modules/nodemailer/lib/smtp-connection/index.js:189:44) at TLSSocket.emit (events.js:376:20) at addChunk (internal/streams/readable.js:309:12) at readableAddChunk (internal/streams/readable.js:284:9) at TLSSocket.Readable.push (internal/streams/readable.js:223:10) { code: 'EAUTH', response: '535-5.7.8 Username and Password not accepted. Learn more at\n' + '535 5.7.8 https://support.google.com/mail/?p=BadCredentials u6sm13346885wrp.0 - gsmtp', responseCode: 535, command: 'AUTH XOAUTH2' }

i added all the emails to test users.

the code

      type: 'oauth2',
      user: req.user.email,
      clientId: clientId,
      clientSecret: clientSecret,
      refreshToken: refreshToken,
  };
  
  var mailOptions = {
      from: req.user.email,
      to: 'email@gmail.com',
      subject: req.query.sbjct,
      text: req.query.msg,
      html: req.query.msg,
  };
  
  var transporter = nodemailer.createTransport({
      service: 'gmail',
      auth: auth,
  });
  
  transporter.sendMail(mailOptions, (err, res) => {
      if (err) {
          return console.log(err);
      } else {
          res.send('done !');
      } ```

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Gmail does not fully allow sending mails from third party apps. So for you to send mails from a third party app (like your app using nodemailer) you need to go to that gmail account settings and lower gmail security for that account [less secure][1]. nodemailer docs

and your createTransport should look like this

    let transporter = nodemailer.createTransport({
    host: "smtp.gmail.email",
    port: 587,
    secure: false, // true for 465, false for other ports
    auth: {
      user: your username, // generated gmail user
      pass: your password, // generated gmail password
    },
  });
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda