作者:肥姐PK老赖 | 来源:互联网 | 2023-09-25 18:43
var nodeMailer = require("nodemailer");/*//0.7.1版本需要设置SMTP参数var transport = nodeMailer.createTransport("SMTP", { host: "smtp.163.com", secureConnection: true, // use SSL port: 465, // port for secure SMTP auth: { user: "xxxxx@163.com", pass: "xxxxxx" }});*/var transport = nodeMailer.createTransport({ service: "163", host: "smtp.163.com", secureConnection: true, // use SSL port: 465, // port for secure SMTP auth: { user: "xxxxx@163.com", pass: "xxxxxx" }});transport.sendMail({ from : "xxxxx@163.com", to : "xxxxx@xxx.com", subject: "邮件主题", html : "这是封测试邮件", attachments: [ // String attachment { filename: 'notes.txt', content: 'Some notes about this e-mail' } ]}, function(error, response){ if(error){ console.log(error); }else{ console.log("Message sent: " + response.message); } transport.close();});