node.js - nodemailer 不发送邮件,给出 250 ok

我整个下午都在处理这个问题,欢迎大家提出意见。 我目前正在运行以下示例代码来定位问题:

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 设置和不使用 - 只要我可以进行身份​​验证,似乎都没有什么不同。

问题是电子邮件永远不会发送,我试过将它发送到一堆不同的电子邮件地址,但没有一个人收到了电子邮件。

最佳答案

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

https://stackoverflow.com/questions/58206033/

相关文章:

selenium - 登录网站时如何使用 puppeteer/selenium 重用保存的凭据/密码

flutter - 如何使用我的整个应用程序在 TabBarView 中创建可滚动的内容?

wordpress - 您无权查看此页面 : JWT Authentication for WP R

visual-studio-code - Prettier 在 React Code 中不工作并在状

apache-spark - 在 Spark 2.4.0 中使用 spark.sql 的 Hive

java - elasticsearch 中的 too_many_buckets_exception

flutter - Google AdMob 奖励视频有时只加载

react-native - null 不是对象(评估 'StripeModule.init' )

java - 创建名为“kafkaListenerContainerFactory”的 bean 时

javascript - 使用 React Hook 应用多个 Context 的好方法