【问题标题】:Nodemail x Node.js: Failed auth although tested with successNodemail x Node.js:虽然测试成功但验证失败
【发布时间】:2020-03-30 17:39:22
【问题描述】:

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

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

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

打印Server is ready to take our messages

然后在设置我的信封并使用.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' }

错误很明显:Failed Auth,但很奇怪,因为测试工作较早!

连接参数为:

// 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 );

提前谢谢大家

【问题讨论】:

  • 您还添加了运输车初始化。
  • 加在问题的最后!
  • 你确定你使用的发件人地址是允许的

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


【解决方案1】:

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

【讨论】:

  • 根据您的经验,使用 DKIM 签名会有帮助吗?
  • 是的,它提高了可交付性。我已在域级别配置 DKIM,以便 Amazon SES 将为使用其服务发送的每封电子邮件添加签名。您是否正在考虑使用 SES
  • 我现在正在使用添加的 DKIM 签名进行测试,如果解决了我会通知你们
  • 它仍然没有改变任何东西,我有完全相同的错误。我真的不知道该怎么办。我拥有对发件人电子邮件的完全访问权限,输入正确的用户名和密码,参数正确,当我登录服务器时,信封看起来不错。
  • 我查看了源代码,导致我的代码失败的原因是:(Number(str.charAt(0)) !== 2) 因为这显然是正确的。我的收件人怎么会退回 2?什么字符的值为 2?
猜你喜欢
  • 1970-01-01
  • 2019-07-15
  • 1970-01-01
  • 2017-12-30
  • 2015-06-24
  • 2011-09-29
  • 2016-09-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多