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

标签 node.js reactjs nodemailer

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

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

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

最佳答案

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

关于node.js - nodemailer 不发送邮件,给出 250 ok,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58206033/

相关文章:

javascript - 同步检查子进程是否未能在 Node 中生成?

javascript - 使用 node.js 流创建一个文件并通过管道传递给 gulp

javascript - 尽管有 React 的 onClick 处理程序,history.back() 似乎并没有等待点击

javascript - 如何在拖动点时降低 Highcharts 中自动轴调整的灵敏度

node.js - 调用函数后运行的 if 语句

json - 使用反斜杠解析 JSON Node.js

javascript - 有没有办法使用 Sequelize 模型方法来表达以下 SQL 查询?

javascript - React-Redux - 如何从子组件分派(dispatch)操作?

node.js - smtp通过postfix发送邮件和nodejs nodemailer连接关闭

node.js - 由于 EAI_AGAIN,电子邮件未在 Docker 容器内使用 Nodemailer 发送