0

嘿,我正在使用 nodemailer 和 send-in-blue 从我的 next.js 应用程序发送邮件。

当我在 netlify 上托管该网站为客户演示时,一切都很顺利。电子邮件发送没有错误,但是当我在 digitalocean 液滴上托管该站点时,它开始抛出以下错误:

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'
}

这是我写的代码:

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,
    });

是的,环境变量工作得很好。

谁能解释发生了什么?提前致谢。

4

1 回答 1

0

尝试在您的 gmail 帐户中启用 IMAP,并在您的 google 帐户中启用“允许不太安全的应用程序”。

如果您使用的是双重身份验证,您可能无法在您的 Google 帐户的安全部分中看到允许安全性较低的应用程序选项。

在这种情况下,您可能需要在您的 goolge 帐户中使用应用程序密码。

于 2021-10-29T21:43:35.310 回答