首页 > 其他 > 详细

nodemailer模块

时间:2018-01-20 14:29:19      阅读:315      评论:0      收藏:0      [点我收藏+]
 1 var nodemailer = require(‘nodemailer‘);
 2 var transporter = nodemailer.createTransport({
 3     //https://github.com/andris9/nodemailer-wellknown#supported-services 支持列表
 4     service: ‘qq‘,
 5     port: 465, // SMTP 端口
 6     secureConnection: true, // 使用 SSL
 7     auth: {
 8         user: ‘1466594176@qq.com‘,
 9         //这里密码不是qq密码,是你设置的smtp密码
10         pass: ‘‘
11     }
12 });

在qq邮箱中点击 “”“设置” =》“账号”

技术分享图片

然后就可以发送邮件了

 1 var mailOptions = {
 2     from: ‘@qq.com‘, // 发件地址
 3     to: ‘@qq.com‘, // 收件列表
 4     subject: ‘查成绩啦‘, // 标题
 5     //text和html两者只支持一种
 6     text: ‘查成绩啦‘, // 标题
 7     html: ‘<b>good luck for myself!</b>‘ // html 内容
 8 };
 9 
10 // send mail with defined transport object
11 transporter.sendMail(mailOptions, function(error, info) {
12     if (error) {
13         return console.log(error);
14     }
15     console.log(‘Message sent: ‘ + info.response);
16 
17 });

其中有哪些邮件可以直接调用,可以查看对于的文档(https://nodemailer.com/smtp/well-known/)

附上查询成绩的js脚本 https://github.com/luguiqing/nodemailer

参考资料 https://www.cnblogs.com/pingfan1990/p/4864822.html

nodemailer模块

原文:https://www.cnblogs.com/luguiqing/p/8320517.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!