var nodemailer=require("nodemailer");var nodemailer=require("nodemailer");var config={host:"smtp.163.com",port:465,auth:{user:"aaaaa@163.com",pass:"aaaa!"}}var transporter=nodemailer.createTransport(config); function sendMail(receiver){var data={from:config.auth.user,to:receiver,subject:"this is a test",html:"<h1>this is a test from nodemailer</h1><p>this is using node to send mail</p>"};transporter.sendMail(data,function(error,info){if(error){console.log(error)}else{cosnole.log(info.response)}})}sendMail(["768838557@qq.com","power998@163.com"])
npm强大的资源,几行代码就能搞定发送邮件;
结果如下: