使用nodemailer发送邮件
https://github.com/nodemailer/nodemailer nodemailer源码的位置
/**
* Created by bamboo on 2016/4/5.
*/
var nodeMailer = require('nodemailer');
var user = '244553933@qq.com',//见笑本人的邮箱
pass = '**********';
var transporter = nodeMailer.createTransport({
host: 'smtp.qq.com', //若是gmail 则使用smtp.gmail.com
secureConnection: true,
port: 465,
auth: {
user: user,
pass: pass
}
});
transporter.sendMail({
from: '244553933@qq.com',
to: '1553453958@qq.com',
subject: 'Node js通过smtp协议从qq邮箱发送邮件',
html: '这是一封测试邮件 <br>'
}, function (err, res) {
"use strict";
console.log(res);
});
npm install nodemailer
node nodeMailer.js
查看是否发送邮件
可以看到从本人的邮箱中,看到已经发送的邮件了,测试完成