Я пытаюсь внедрить систему проверки электронной почты, используя 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: "[email protected]", // TODO: email sender
to: "[email protected]", // 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: "[email protected]", // TODO: email sender
to: "[email protected]", // TODO: email receiver
subject: "Account Verfication",
html: html, // key should be html
};
// Step 3
transporter.sendMail(mailOptions, (err, data) => {
if (err) return log(err);
});