【发布时间】:2019-11-17 02:28:03
【问题描述】:
我正在使用 nodemailer 通过我的节点应用程序发送电子邮件。有时电子邮件不起作用并引发错误,直到我尝试两次或三次。我希望我的程序一次又一次地尝试,直到邮件成功发送。
这是我的代码:
const mailOptions = {
from: from,
to: client.email,
subject: 'Your Photos are ready',
html: mailTemplate
};
transporter.sendMail(mailOptions, function(error, info){
if (error) {
res.status(500).json({
message: "Mail not sent",
error
});
} else {
res.status(200).json({message: "Mail Sent", response: info.response});
}
});
如何在 if 块中使用相同的功能?
【问题讨论】:
标签: javascript node.js express nodemailer