let transporter = nodemailer.createTransport({
service: "Outlook365",
host: 'smtp.office365.com',
port: 587,
tls: {
ciphers:'SSLv3'
},
auth: {
user: 'username',
pass: 'password'
}
});我有一个EAUTH错误,同时发送电子邮件,请检查图像的错误。1:https://i.stack.imgur.com/snt3T.jpg
发布于 2020-10-02 06:51:56
这段代码应该做你想做的事情,你需要设置你的密码来测试它。
如果密码不正确,您将得到一个错误:
错误:无效登录: 535 5.7.3身份验证不成功消息。
const nodemailer = require('nodemailer');
// Set this from config or environment variable.
const PASSWORD = '....';
async function send365Email(from, to, subject, html, text) {
try {
const transportOptions = {
host: 'smtp.office365.com',
port: '587',
auth: { user: from, pass: PASSWORD },
secureConnection: true,
tls: { ciphers: 'SSLv3' }
};
const mailTransport = nodemailer.createTransport(transportOptions);
await mailTransport.sendMail({
from,
to,
replyTo: from,
subject,
html,
text
});
} catch (err) {
console.error(`send365Email: An error occurred:`, err);
}
}
send365Email("from@example.com", "to@example.com", "Subject", "<i>Hello World</i>", "Hello World");发布于 2022-09-12 18:34:45
您需要使用以下命令通过联机power shell禁用SmtpClientAuthenticationDisabled
Set-TransportConfig -SmtpClientAuthenticationDisabled $false您可以在在Exchange Online中启用或禁用经过身份验证的客户端SMTP提交(SMTP AUTH)查看更多信息。
发布于 2022-05-05 03:56:42
https://stackoverflow.com/questions/64166563
复制相似问题