var nodemailer = require('nodemailer'); // create reusable transporter object using SMTP transport var transporter = nodemailer.createTransport({ service: 'Gmail', auth: { user: 'xxx@xxx', pass: 'xxxx' } }); transporter.sendMail({ from: 'xxx', to: 'xxxx', subject: 'hello', text: 'hello world!' }, function(error, info){ if(error){ console.log(error); }else{ console.log('Message sent: ' + info.response); } });
错误提示
{ [Error: Invalid login]}
解决方法:
http://stackoverflow.com/questions/19877246/nodemailer-with-gmail-and-nodejs
http://stackoverflow.com/questions/19877246/nodemailer-with-gmail-and-nodejs
将这里的选项改成启用就可以发送email了