【问题标题】:nodemailer not sending mail, giving 250 oknodemailer不发送邮件,给出250 ok
【发布时间】:2022-02-15 16:21:07
【问题描述】:

我整个下午都在处理这个问题,欢迎所有想法。 我目前正在运行以下示例代码来定位问题:

router.get('/', function(req, res, next) {
let transporter = nodemailer.createTransport({
    host: "cpsrv14.misshosting.com",
    port: 587,
    secure: false,
    auth: {
        user: config.email.user,
        pass: process.env.EMAIL_PASS
    },
    tls: {
        rejectUnauthorized: false
    }
});

// verify connection configuration
transporter.verify(function(error, success) {
    if (error) {
        console.log(error);
    } else {
        console.log("Server is ready to take our messages");
    }
});

transporter.sendMail({
    from: '"Fred Foo ????" <foo@example.com>', // sender address
    to: 'christopher.rosenvall@gmail.com', // list of receivers
    subject: 'Hello ✔', // Subject line
    text: 'Hello world?', // plain text body
    html: '<b>Hello world?</b>' // html body
}).then(resp => {
    console.log('Message sent: %s', JSON.stringify(resp));
    res.status(200).json({
        success: true
    })
}).catch( err => {
    console.log(err);
    res.status(400)
});

});

应请求控制台为我提供以下对我来说似乎没问题的信息:

Server is ready to take our messages

Message sent: {"accepted":["christopher.rosenvall@gmail.com"],"rejected":
[],"envelopeTime":84,"messageTime":403,"messageSize":603,"response":"250 OK id=1iFhm4-0004WG-
NM","envelope":{"from":"foo@example.com","to":["christopher.rosenvall@gmail.com"]},"messageId":"
<7f8f8aab-f900-1e8e-2cde-3da5ad2687ba@example.com>"}

GET / 200 762.254 ms - 16

我尝试过使用安全运行而不是安全运行,使用 tls 设置和不使用 - 只要我可以进行身份​​验证,似乎没有什么不同。

问题是电子邮件从未发送过,我尝试将其发送到一堆不同的电子邮件地址,但没有一个收到电子邮件。

【问题讨论】:

  • 谢谢,但我没有运行自己的 smtp 服务器。我正在连接到第 3 方服务。另一个奇怪的事情是它在我的生产环境中使用相同的代码,唯一的区别是它在 ubuntu 服务器上运行 https 而我的 localhost dev 是 http windows。
  • 您找到解决问题的方法了吗?我也收到了250 ok,但实际上并未发送电子邮件。 (使用 GMail API。)
  • 是的,正如我在下面的评论中所说,我重新安装了项目,突然一切正常。

标签: node.js reactjs nodemailer


【解决方案1】:

我重新安装了项目,现在一切正常,奇怪。

【讨论】:

    【解决方案2】:

    仔细检查您是否在选项中给予。我遇到了这个问题。就我而言,我没有在选项字段中提供。但是从:fromemail@mail.com 获得后一切正常

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-10-06
      • 2017-12-22
      • 1970-01-01
      • 2016-06-18
      • 1970-01-01
      • 2017-12-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多