无法使用 outlook 设置 nodemailer
Can't setup nodemailer with outlook
我正在使用 "nodemailer":“^4.6.8”和 "nodemailer-smtp-transport":“^2.7.4”。我正在我的网站上开发联系表格并尝试通过 outlook 发送表格邮件。从互联网上的一些示例中,我尝试了这段代码,其中 xxxxx@hotmail.com 是我的电子邮件地址:
const transport = nodemailer.createTransport({
service: "Hotmail",
auth: {
user: "xxxxx@hotmail.com",
pass: "xxxxxxxx"
}
});
var mailOptions = {
from: 'somemail@mail.com', // sender address
to: 'xxxxx@hotmail.com', // my mail
subject: `message subject`, // Subject line
text: 'plain text', // plain text body
// html: params.html, // html body
// attachments: params.attachments
};
transport.sendMail(mailOptions, (error, info) => {
if (error) {
return console.log('Error while sending mail: ' + error);
} else {
console.log('Message sent: %s', info.messageId);
}
transport.close(); // shut down the connection pool, no more messages.
});
但是这段代码在控制台中给出了错误:
Error while sending mail: Error: Message failed: 554 5.2.0 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. 16.55847:62090000, 17.43559:0000000094000000000000000100000000000000, 20.52176:140FCC84140010100A00FE67, 20.50032:140FCC84841710100B004536, 0.35180:6E060000, 255.23226:0A000055, 255.27962:0A000000, 255.27962:0E000000, 255.31418:80030400, 16.55847:AC000000, 17.43559:0000000068010000000000000200000000000000, 20.52176:140FCC8414001010D5050000, 20.50032:140FCC8484171010DA050000, 0.35180:0A001286, 255.23226:DF050000, 255.27962:0A000000, 255.27962:32000000, 255.17082:DC040000, 0.27745:E9050000, 4.21921:DC040000, 255.27962:FA000000, 255.1494:0A005384, 0.37692:01000100, 0.37948:00000600, 5.33852:00000000534D545000000100, 4.56248:DC040000, 7.40748:010000000000010B32303A48, 7.57132:000000000000000039313A36, 1.63016:32000000, 4.39640:DC040000, 8.45434:00000600ED8A4ABA000000000000000036000000, 5.10786:0000000031352E32302E313232382E3032303A4845315052303830314D42323039313A36646663323235632D353465312D346233312D383138612D3134643735373464633538620000000000, 255.1750:2F060000, 255.31418:40000730, 0.22753:34060000, 255.21817:DC040000, 4.60547:DC040000, 0.21966:0A001780, 4.30158:DC040000 [Hostname=HE1PR0801MB2091.eurprd08.prod.outlook.com]
不知道该怎么做,提前致谢!
事实证明代码正确,这是安全问题。我只能从我的帐户发送信件,不能从任何其他人发送信件,因此使用邮寄选项一切正常:
let mailOptions = {
from: 'xxxxx@hotmail.com', // sender address
to: 'xxxxx@hotmail.com', // list of receivers
subject: `subject`, // Subject line
text: 'text', // plain text body
// html: html, // html body
// attachments: attachments
};
我正在使用 "nodemailer":“^4.6.8”和 "nodemailer-smtp-transport":“^2.7.4”。我正在我的网站上开发联系表格并尝试通过 outlook 发送表格邮件。从互联网上的一些示例中,我尝试了这段代码,其中 xxxxx@hotmail.com 是我的电子邮件地址:
const transport = nodemailer.createTransport({
service: "Hotmail",
auth: {
user: "xxxxx@hotmail.com",
pass: "xxxxxxxx"
}
});
var mailOptions = {
from: 'somemail@mail.com', // sender address
to: 'xxxxx@hotmail.com', // my mail
subject: `message subject`, // Subject line
text: 'plain text', // plain text body
// html: params.html, // html body
// attachments: params.attachments
};
transport.sendMail(mailOptions, (error, info) => {
if (error) {
return console.log('Error while sending mail: ' + error);
} else {
console.log('Message sent: %s', info.messageId);
}
transport.close(); // shut down the connection pool, no more messages.
});
但是这段代码在控制台中给出了错误:
Error while sending mail: Error: Message failed: 554 5.2.0 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. 16.55847:62090000, 17.43559:0000000094000000000000000100000000000000, 20.52176:140FCC84140010100A00FE67, 20.50032:140FCC84841710100B004536, 0.35180:6E060000, 255.23226:0A000055, 255.27962:0A000000, 255.27962:0E000000, 255.31418:80030400, 16.55847:AC000000, 17.43559:0000000068010000000000000200000000000000, 20.52176:140FCC8414001010D5050000, 20.50032:140FCC8484171010DA050000, 0.35180:0A001286, 255.23226:DF050000, 255.27962:0A000000, 255.27962:32000000, 255.17082:DC040000, 0.27745:E9050000, 4.21921:DC040000, 255.27962:FA000000, 255.1494:0A005384, 0.37692:01000100, 0.37948:00000600, 5.33852:00000000534D545000000100, 4.56248:DC040000, 7.40748:010000000000010B32303A48, 7.57132:000000000000000039313A36, 1.63016:32000000, 4.39640:DC040000, 8.45434:00000600ED8A4ABA000000000000000036000000, 5.10786:0000000031352E32302E313232382E3032303A4845315052303830314D42323039313A36646663323235632D353465312D346233312D383138612D3134643735373464633538620000000000, 255.1750:2F060000, 255.31418:40000730, 0.22753:34060000, 255.21817:DC040000, 4.60547:DC040000, 0.21966:0A001780, 4.30158:DC040000 [Hostname=HE1PR0801MB2091.eurprd08.prod.outlook.com]
不知道该怎么做,提前致谢!
事实证明代码正确,这是安全问题。我只能从我的帐户发送信件,不能从任何其他人发送信件,因此使用邮寄选项一切正常:
let mailOptions = {
from: 'xxxxx@hotmail.com', // sender address
to: 'xxxxx@hotmail.com', // list of receivers
subject: `subject`, // Subject line
text: 'text', // plain text body
// html: html, // html body
// attachments: attachments
};