1

Hey I'm using nodemailer along with send-in-blue to send mails from my next.js application.

Everything went smoothly when I hosted the site on netlify for demonstrate for a client. Emails were sent with no errors, but when I hosted the site on a digitalocean droplet it started to throw the following error:

Error: Invalid login: 530 Invalid username or password
    at SMTPConnection._formatError (/app/node_modules/nodemailer/lib/smtp-connection/index.js:784:19)
    at SMTPConnection._actionAUTHComplete (/app/node_modules/nodemailer/lib/smtp-connection/index.js:1536:34)
    at SMTPConnection.<anonymous> (/app/node_modules/nodemailer/lib/smtp-connection/index.js:540:26)
    at SMTPConnection._processResponse (/app/node_modules/nodemailer/lib/smtp-connection/index.js:947:20)
    at SMTPConnection._onData (/app/node_modules/nodemailer/lib/smtp-connection/index.js:749:14)
    at TLSSocket.SMTPConnection._onSocketData (/app/node_modules/nodemailer/lib/smtp-connection/index.js:189:44)
    at TLSSocket.emit (node:events:394:28)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:289:9)
    at TLSSocket.Readable.push (node:internal/streams/readable:228:10) {
  code: 'EAUTH',
  response: '530 Invalid username or password',
  responseCode: 530,
  command: 'AUTH PLAIN'
}

This is the code I wrote:

const transporter = nodemailer.createTransport({
      service: "SendinBlue",
      auth: {
        user: process.env.SEND_IN_BLUE_USER,
        pass: process.env.SEND_IN_BLUE_PASS,
      },
    });

const transporterRes = await transporter.sendMail({
      to: stringifiedEmails,
      from: email,
      subject: "test",
      html,
    });

And yes the environmental variables are working just fine.

Can anyone explain what's going on? Thanks in advance.

Goutham
  • 11
  • 2

1 Answers1

0

Try to enable IMAP in your gmail account, and "Allow less Secure Apps" in your google account.

If you are using two factor authentication, you might not be able to see Allow Less Secure Apps option in Security section in your google account.

In that case you might need to use app passwords in your goolge account.

MRK
  • 87
  • 1
  • 8