【发布时间】:2016-10-14 14:13:12
【问题描述】:
我正在使用 Sendgrid npm 模块通过 node.js 向我的客户发送电子邮件,现在我在这里遇到了一个问题,当我向不存在的电子邮件发送电子邮件时,我的电子邮件被退回,但在我的回复中在我的服务器代码上,我得到了“成功”,但在我的 sendgrid 的仪表板上,它显示我的电子邮件被退回,现在谁能告诉我如何在我的代码中知道我的代码是退回还是成功发送。
我的代码如下
var options = {
auth: {
api_user: 'abc',
api_key: 'pass'
}
}
var mailer = nodemailer.createTransport(sgTransport(options));
var email = {
to: email_id,
from: 'noreply@abc.com',
subject: 'ABC Verification Code',
text: "Your ABC Verification Code is " + totp
// html: '<b>Awesome sauce</b>'
};
mailer.sendMail(email, function(err, res) {
if (err) {
console.log(err);
res.json({success : 0, message : "Sorry Please try Again"});
return next();
} else {
console.log('res: ', res);
res.json({success : 1, message : "Successfully Sent Otp To Email Id"});
return next();
}
});
还有一个问题,当我使用未订阅的组 ID 发送电子邮件时,我的电子邮件总是在 gmail 的“促销”部分发送,谁能告诉我如何在 gmail 的“更新”部分向用户显示我的电子邮件.
【问题讨论】: