nodejs配置QQ企业邮箱

安装模块

npm install -g nodemailer
npm install -g nodemailer-smtp-transport

代码示例


var nodemailer = require('nodemailer') 
var smtpTransport = require('nodemailer-smtp-transport');

smtpTransport = nodemailer.createTransport(smtpTransport({
    host: "smtp.exmail.qq.com",
    port:465,
    auth: {
        user: "[email protected]",
        pass: "Sz5M7sfSSSSeCia" //这是邮箱的授权码不是登录密码。 安全登录的客户端专用密码:
    }
}));

var sendMail = function (recipient, subject, html) {

    smtpTransport.sendMail({

        from: "[email protected]",
        to: "[email protected]",
        subject: "代理超时",
        html: "代理错误"

    }, function (error, response) {
        if (error) {
            console.log(error);
        }
        console.log('发送成功')
    });
}

//module.exports = sendMail

sendMail()

猜你喜欢

转载自www.cnblogs.com/c-x-a/p/11532118.html