我正在尝试将电子邮件从 gmail 帐户发送到我的大学电子邮件 Outlook.office365 的接收者。 它适用于 gmail 到 gmail、gmail 到 outlook.live、gmail 到 yahoo
import * as nodemailer from 'nodemailer';
export const send = async (to, from, subject, html) => {
// let testAccount = await nodemailer.createTestAccount();
let transporter = nodemailer.createTransport({
name: 'Example',
service: 'gmail',
secure : false,
port : 587,
auth: {
user: process.env.FROM_EMAIL,
pass: process.env.PASSWORD,
},
});
transporter.verify(function(error, success) {
if (error) {
console.log(error);
} else {
console.log("Server is ready to take our messages");
}
});
let info = await transporter.sendMail(
{
from,
to ,
subject,
html,
},
(err, info) => {
if (err) {
console.log(err);
}
console.log(info)
},
);
};
答案 0 :(得分:0)
没关系,我找到了解决方案,显然 Outlook 不接受电子邮件中的 html,如果您将 html 属性更改为文本,它将被发送。