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: "xxxx@xxx.com",
pass: "Sz5M7sfSSSSeCia" //这是邮箱的授权码不是登录密码。 安全登录的客户端专用密码:
}
}));
var sendMail = function (recipient, subject, html) {
smtpTransport.sendMail({
from: "xxx@xxxx.com",
to: "xxx@xxx.com",
subject: "代理超时",
html: "代理错误"
}, function (error, response) {
if (error) {
console.log(error);
}
console.log('发送成功')
});
}
//module.exports = sendMail
sendMail()