NodeJS 使用 nodemailer 发送邮件

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 " ', // sender address
    to: "[email protected]", // list of receivers
    subject: "Hello ✔", // Subject line
    // text: "Hello world?", // plain text body
    html: `
        点击激活
        
        `
};

transporter.sendMail(mailContent, (error, data) => {
    console.log(error, data.messageId); //<[email protected]>
});

// module.exports = function () {
//     transporter.sendMail(mailContent, (error, data) => {
//         console.log(error, data.messageId); //<[email protected]>
//     });
// };

你可能感兴趣的:(nodejs)