const qqAuthCode = "xxxxxx", //邮件端生成的认证码,而不是 QQ 密码
nodeMailer = require("nodemailer"),
http = require("http");
let transporter = nodeMailer.createTransport({
host: "smtp.qq.com",
port: 465,
secure: true,
auth: {
user: "qq号码",
pass: qqAuthCode
}
});
let mailContent = {
from: '"Fred Foo 👻" <xxxxxxx@qq.com>', // sender address
to: "xxxxxxxxxxx@qq.com", // list of receivers
subject: "Hello ✔", // Subject line
// text: "Hello world?", // plain text body
html: `
<a href="http://192.168.0.x:3000/html/activate.html">点击激活</a>
<img src="http://192.168.0.x:3000/img/23.jpg">
`
};
transporter.sendMail(mailContent, (error, data) => {
console.log(error, data.messageId); //<4066ed37-6fc6-2bec-ba06-06a3345d0853@qq.com>
});
// module.exports = function () {
// transporter.sendMail(mailContent, (error, data) => {
// console.log(error, data.messageId); //<4066ed37-6fc6-2bec-ba06-06a3345d0853@qq.com>
// });
// };
NodeJS 使用 nodemailer 发送邮件
最新推荐文章于 2024-03-14 11:52:25 发布