【问题标题】:Nodemailer "connect ETIMEDOUT" with custom domainNodemailer“连接ETIMEDOUT”与自定义域
【发布时间】:2020-08-09 12:54:20
【问题描述】:

我在 Node.js 中创建了一个忘记密码的后端路由,并尝试使用 nodemailer 从我从 namecheap.com 购买的自定义域以及电子邮件域发送电子邮件。我不确定这是否是主机、端口/安全或身份验证的问题。但是,当我更改主机时,它会给出一个 ECONREFUSED 错误,所以我相信该部分正在工作。我的防火墙(据我所知)被禁用并且我重新启动,但是由于 Norton Antivirus 控制它,所以很难判断。

这是我的代码,取自我后端的 router.get 路由。

完整的错误是“连接 ETIMEDOUT”,然后是一个带有 :587 的 IP 地址。

const transporter = createTransport({
        host: 'axotl.com',
        port: 587,
        secure: false,
        auth: {
            user: config.get('emailUser'),
            pass: config.get('emailPass')
        }
    });
    let resetLink = '';
    let authToken = '';
    await jwt.sign({ email: req.params.email }, config.get('JWTSecret'), { expiresIn: 10800000 }, (err, token) => {
        if (err) throw err;
        authToken += token;
    })
    resetLink = await `${config.get('productionLink')}/recipients/resetpassword/${authToken}`
    console.log(`resetlink : ${resetLink}`)
    const mailOptions = {
        from: '"Axotl Support" <support@axotl.com>',
        to: req.params.email,
        subject: "Forgot Password",
        text: `Hello ${req.name},\n\nHere is the password reset link you requested (expires in 3 hours): ${resetLink}\nIf you did not request this, please notify us at http://axotl.com/support\n\nThanks!\n-Axotl Support`
    }
    try {
        console.log('trycatch entered')
            // const verified = await transporter.verify()
            // console.log(`verified : ${verified}`)
        const res = await transporter.sendMail(mailOptions)
        console.log('email completed')
        console.log(res)

        res.json({ msg: "email sent" })
    } catch (err) {
        console.error(err.message);
        res.status(500).send("Server Error")
    }

【问题讨论】:

  • 你能telnet到axotl.com的587端口吗?
  • 即使我通过诺顿禁用了防火墙,Telnet 也无法打开连接。设置对此有点混乱,因为 windows 说诺顿可以控制我的防火墙,但是当我禁用诺顿的防火墙时,它似乎并没有完全禁用 windows 防御者防火墙。

标签: node.js nodemailer


【解决方案1】:

原来我使用了错误的主机域——该服务没有直接在网站上托管电子邮件域。我对这个特定部分的了解不够。我将其更改为电子邮件主机,并且有效。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-12-24
    • 1970-01-01
    • 2022-10-21
    • 2018-06-18
    • 1970-01-01
    • 1970-01-01
    • 2018-04-25
    • 1970-01-01
    相关资源
    最近更新 更多