安装模块
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()转载于:https://www.cnblogs.com/c-x-a/p/11532118.html
相关资源:JAVA上百实例源码以及开源项目