具有自定义域的节点邮件程序"connect ETIMEDOUT"



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

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

完整的错误是"connect 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},nnHere 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/supportnnThanks!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")
}

发现我使用了错误的主机域——该服务不会直接在网站上托管电子邮件域。我对这个特定部分了解不够。我把它改成了电子邮件主机,它起了作用。

相关内容

最新更新