使用nodemailer和nodemailer-sendgrid-transport会显示以下错误
错误:发件人地址与验证的发件人身份不匹配。解决此错误之前,无法发送邮件。访问https://sendgrid.com/docs/for-developers/sending-email/sender-identity/以查看发件人身份要求
`const nodemailer=require('nodemailer');
const sendGridTranspoter=require('nodemailer-sendgrid-transport')
const transport=nodemailer.createTransport(sendGridTranspoter({
service: 'SendGrid',
auth:{
api_user:'myuser name',
api_key:'password'
}));
`
这是我的注册控制器功能内部
var email = {
from: 'sener email',
to: 'receiver valid email',
subject: 'shopMe',
text: 'successfully sign up',
html: '<b>Hello world</b>'
};
transport.sendMail (email, function(err, info){
if (err ){
console.log(err);
}
else {
console.log('Message sent: ' + info.response);
}
});
答案 0 :(得分:2)
有两种可能的方法, 1.在您的Google Mail安全中允许安全性较低的应用“启用” 2.转到sendgrid,单击“市场营销”,然后单击“发件人”,填写详细信息并进行检查