node.js - Node.js 中的 Nodemailer : Failed auth although tested with success

标签 node.js firebase google-cloud-functions nodemailer

我在使用应该通过 SMTP 传输器发送电子邮件的 nodemailer Firebase 功能时遇到问题。

这很奇怪,因为我正在使用以下方法测试我的连接是否成功:

// check server readiness
const serverReady = await new Promise<boolean>(resolve => {
  transporter.verify( (err: any, succ: any) => {
    if (err) {
      console.log(err);
      resolve(false);
    } else {
      console.log('Server is ready to take our messages');
      resolve(true);
    }
  });
})

打印服务器已准备好接收我们的消息

然后在设置我的信封并使用 .sendMail 方法发送后,我收到此错误:

Unhandled error { Error: Mail command failed: 530 5.5.1 Authentication Required.
    at SMTPConnection._formatError (/srv/node_modules/nodemailer/lib/smtp-connection/index.js:777:19)
    at SMTPConnection._actionMAIL (/srv/node_modules/nodemailer/lib/smtp-connection/index.js:1546:34)
    at SMTPConnection._responseActions.push.str (/srv/node_modules/nodemailer/lib/smtp-connection/index.js:1028:18)
    at SMTPConnection._processResponse (/srv/node_modules/nodemailer/lib/smtp-connection/index.js:935:20)
    at SMTPConnection._onData (/srv/node_modules/nodemailer/lib/smtp-connection/index.js:742:14)
    at TLSSocket.SMTPConnection._onSocketData.chunk (/srv/node_modules/nodemailer/lib/smtp-connection/index.js:195:44)
    at emitOne (events.js:116:13)
    at TLSSocket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at TLSSocket.Readable.push (_stream_readable.js:208:10)
    at TLSWrap.onread (net.js:601:20)
  code: 'EENVELOPE',
  response: '530 5.5.1 Authentication Required.',
  responseCode: 530,
  command: 'MAIL FROM' }

错误非常明显:身份验证失败,但很奇怪,因为测试之前就成功了!

连接参数为:

// options to connect to server
const smtpOptions = {
  host: 'smtp.zoho.eu',
  port: 465,
  secure: true,
  auth: {
    user: functions.config().nodemailer.user,
    pass: functions.config().nodemailer.pass
  }
};

// transporter for sending the email
const transporter = nodeMail.createTransport( smtpOptions );

先谢谢大家了

最佳答案

transporter.verify 仅测试连接和身份验证,看起来您无权使用特定的 MAIL FROM 地址。

关于node.js - Node.js 中的 Nodemailer : Failed auth although tested with success,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59201089/

相关文章:

firebase - 当来自 rnfirebase 的 firestore 包时,数据未存储在 Firestore 中

javascript - 为什么 Node mkdirSync() 会抛出异常?

android - Algolia Firebase 和 Android 集成

node.js - NestJs:SCRAM-SERVER-FIRST-MESSAGE:客户端密码必须是字符串

firebase - 仅获取 Firestore 中的文档名称

javascript - Firestore云功能。https.onRequest Request.url.split ("/")不起作用

firebase - 从云函数调用 auto ml api 时资源 ID 无效

javascript - Firebase 部署函数发送推送通知时出错

javascript - 将异步函数传递给 Node.js Express.js 路由器

javascript - 如何在 Node js 中使用 forEachLimit