标签:
1、安装 npm install nodemailer
https://github.com/andris9/Nodemailer
2、配置发邮件的账户开启SMTP功能;
3、程序样例如下:
var nodemailer = require(‘nodemailer‘); var user = ‘fredric@XXXX.com‘, password = ‘XXXX‘; // create reusable transporter object using SMTP transport var transporter = nodemailer.createTransport({ service: ‘QQ‘, auth: { user: user, pass: password } }); // setup e-mail data with unicode symbols var mailOptions = { from: ‘Fredric<‘ + user + ‘>‘, // sender address to: ‘Fredric@qq.com‘, // list of receivers subject: ‘Hello ?‘, // Subject line text: ‘Hello world ?‘, // plaintext body html: ‘<b>Hello world ?</b>‘ // html body }; // send mail with defined transport object transporter.sendMail(mailOptions, function(error, info){ if(error){ console.log(error); }else{ console.log(‘Message sent: ‘ + info.response); } });
标签:
原文地址:http://www.cnblogs.com/Fredric-2013/p/4287655.html