【问题标题】:Nodemailer: How to get a response of fail to send?Nodemailer:如何获得发送失败的响应?
【发布时间】:2022-11-01 14:06:57
【问题描述】:

我正在尝试通过 nodemailer 制作电子邮件系统。

尽管收件人地址错误,它始终有效。

我得到了回应:

{
  accepted: [ '******' ],
  rejected: [],
  envelopeTime: 97,
  messageTime: 211,
  messageSize: 664,
  response: '250 2.0.0 OK <******> [Hostname=*******]',
  envelope: { from: '*******', to: [ '******' ] },
  messageId: '<*******>'
}

由于收件人地址错误导致发送失败时如何获得响应?

我的代码是:


let transport = nodemailer.createTransport({
  host: "smtp.office365.com",
  port: 587,
  auth: {
    user: "*******",
    pass: "*******",
  },
  secure: false
});


transport.sendMail(mailOptions, (err, info) => {
  if (err) {
    return console.log(err);
  } else {
    console.log(info);
    console.log("Message sent: %s", info.pending);
  }
  transport.close();
});

我知道 'transport.sendMail()' 中的 'err' 是针对电子邮件系统错误时的。

而且我希望当收件人出错时我也能得到退货/回复。

【问题讨论】:

    标签: node.js nodemailer


    【解决方案1】:

    这不是 Nodemailer 的工作,而是服务提供商的工作。您正在使用哪一个,他们是否会在未能联系到不存在的收件人时提供响应,这将是您在购买服务之前提出的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-02
      • 2021-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-10
      相关资源
      最近更新 更多