下面是用于发送邮件的示例代码。
var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport({
host: 'smtp.office365.com',
port: 587,
auth: {
user: 'me@myserver.com',
pass: 'mypassword'
}
});
var mailOptions = {
from: 'no-reply@myserver.com', //It will work if i give me@myserver.com but i need no-reply@myserver.com in from option.
to: 'someuser@gmail.com',
subject: 'Sending Email using Node.js',
text: 'That was easy!'
};
transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});
如果我在选项中使用no-reply@myserver.com
,我会给我下面的错误。
错误:消息失败:554 5.2.0 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; 由于消息的永久异常,无法处理消息 无法提交消息。
答案 0 :(得分:0)
某些电子邮件服务器不接受更改 FROM 地址。这与nodemailer
无关。您需要检查电子邮件服务器配置。