-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemail.js
More file actions
59 lines (57 loc) · 1.89 KB
/
email.js
File metadata and controls
59 lines (57 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const nodemailer = require("nodemailer");
const emailjs = require("emailjs");
module.exports = function email(options) {
console.log(this)
this.add("role:email,cmd:send", (args, done) => {
var server = emailjs.server.connect({
user: "1187712426@qq.com",
password: "dqmwdlcyijtwbagi",
host: "smtp.qq.com",
ssl: true
});
// send the message and get a callback with an error or details of the message that was sent
server.send(
{
from: "1187712426@qq.com",
to: "1261435326@qq.com,2756586632@qq.com",
subject: "邮件微服务测试",
text:
"send the message and get a callback with an error or details of the message that was sent"
},
(err, msg) => {
if (err) {
done(null, { err });
return;
}
done(null, { msg });
}
);
// var transporter = nodemailer.createTransport({
// service: "qq",
// auth: {
// user: "1187712426@qq.com",
// //授权码,通过QQ获取
// pass: "dqmwdlcyijtwbagi"
// }
// });
// var mailOptions = {
// from: "1187712426@qq.com",
// to: "1262435326@qq.com",
// subject: "nodemailer2.5.0邮件发送", //text: 'Hello world', // 文本 // 发送者 // 接受者,可以同时发送多个,以逗号隔开 // 标题
// html: `<h2>nodemailer基本使用:</h2><h3>
// <a href="http://blog.csdn.net/zzwwjjdj1/article/details/51878392">
// http://blog.csdn.net/zzwwjjdj1/article/details/51878392</a></h3>`
// };
// transporter.sendMail(mailOptions, function(err, info) {
// if (err) {
// done(null, err);
// return;
// }
// done(null, { msg: "发送成功" });
// });
});
this.wrap("role:email", function(msg, respond) {
// console.log(msg)
this.prior(msg, respond);
});
};