当前位置: 首页 > 工具软件 > Nodemailer > 使用案例 >

nodemailer

澹台欣怿
2023-12-01



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强大的资源,几行代码就能搞定发送邮件;

结果如下:


当然,详细配置还要去看官方api,地址如下

https://www.npmjs.com/package/nodemailer


 类似资料: