原始 HTML 正在通过我的网络应用程序发送

Raw HTML is being sent through my web app

我正在尝试使用 nodemailer 为我的网站实施电子邮件验证系统,但它向用户发送原始 html。请帮忙


var html = '<h1>Hello !</h1><p>This is some content \
that will display. You can even inject your first name,  \
in the code.</p><p><a href="http://www.google.com">Search</a> for \
stuff on the Google website.</p>';
let mailOptions = {
  from: "abc@gmail.com", // TODO: email sender
  to: "example@gmail.com", // TODO: email receiver
  subject: "Account Verfication",
  text: html,
};

// Step 3
transporter.sendMail(mailOptions, (err, data) => {
  if (err) return log(err);
});

您正在以文本形式发送。请改用“html”键。参见 https://nodemailer.com/message/

参考 - https://nodemailer.com/about/
您需要为 html 内容使用 html 密钥。

var html = '<h1>Hello !</h1><p>This is some content \
that will display. You can even inject your first name,  \
in the code.</p><p><a href="http://www.google.com">Search</a> for \
stuff on the Google website.</p>';
let mailOptions = {
  from: "abc@gmail.com", // TODO: email sender
  to: "example@gmail.com", // TODO: email receiver
  subject: "Account Verfication",
  html: html, // key should be html
};

// Step 3
transporter.sendMail(mailOptions, (err, data) => {
  if (err) return log(err);
});