zet-lib 1.0.72 → 1.0.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Mail.js +57 -58
- package/lib/Util.js +925 -945
- package/lib/zRoute.js +59 -45
- package/package.json +1 -1
package/lib/Mail.js
CHANGED
|
@@ -1,70 +1,69 @@
|
|
|
1
|
-
const nodemailer = require('nodemailer')
|
|
2
|
-
const ejs = require('ejs')
|
|
3
|
-
const Util = require('./Util')
|
|
4
|
-
const debug = require(
|
|
5
|
-
const io = require(
|
|
6
|
-
const moment = require(
|
|
7
|
-
const config = require('dotenv').config()
|
|
8
|
-
const dirRoot = process.env.dirRoot
|
|
1
|
+
const nodemailer = require('nodemailer')
|
|
2
|
+
const ejs = require('ejs')
|
|
3
|
+
const Util = require('./Util')
|
|
4
|
+
const debug = require('./debug')
|
|
5
|
+
const io = require('./io')
|
|
6
|
+
const moment = require('moment')
|
|
7
|
+
const config = require('dotenv').config()
|
|
8
|
+
const dirRoot = process.env.dirRoot
|
|
9
9
|
|
|
10
|
-
const MAIL = {}
|
|
10
|
+
const MAIL = {}
|
|
11
11
|
//process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
12
12
|
|
|
13
13
|
let mailOptions = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
14
|
+
from: 'sintret@gmail.com',
|
|
15
|
+
to: 'sintret@gmail.com',
|
|
16
|
+
subject: 'haii subject',
|
|
17
|
+
text: 'hi text',
|
|
18
|
+
html: '<p>hi text</p>',
|
|
19
|
+
}
|
|
20
20
|
|
|
21
21
|
MAIL.gmailTransporter = (user, pass) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
22
|
+
return nodemailer.createTransport({
|
|
23
|
+
service: 'gmail',
|
|
24
|
+
auth: {
|
|
25
|
+
user: user,
|
|
26
|
+
pass: pass,
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
30
|
|
|
31
31
|
MAIL.send = function (options, transporter = null) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
32
|
+
let option = Object.assign(mailOptions, options)
|
|
33
|
+
// send mail with defined transport object
|
|
34
|
+
option.user = option.user || 'aptiwise@gmail.com'
|
|
35
|
+
option.pass = option.pass || 'affi ftqv ceal zzwe'
|
|
36
|
+
transporter = transporter || MAIL.gmailTransporter(option.user, option.pass)
|
|
37
|
+
transporter.sendMail(options, function (error, info) {
|
|
38
|
+
if (error) {
|
|
39
|
+
return console.log(error)
|
|
40
|
+
}
|
|
41
|
+
return `Message sent: ${info.response}`
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
};
|
|
45
|
+
MAIL.forgotPassword = (datas, options) => {
|
|
46
|
+
ejs.renderFile(`${dirRoot}/views/layouts/email/forgot_password.ejs`, { data: datas, Util: Util }, function (err, data) {
|
|
47
|
+
let option = Object.assign(mailOptions, options)
|
|
48
|
+
option.html = data
|
|
49
|
+
if (err) {
|
|
50
|
+
console.log(err)
|
|
51
|
+
} else {
|
|
52
|
+
MAIL.send(option)
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
}
|
|
57
56
|
|
|
58
57
|
MAIL.register = (datas, options) => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
58
|
+
ejs.renderFile(`${dirRoot}/views/layouts/email/register.ejs`, { data: datas, Util: Util }, function (err, data) {
|
|
59
|
+
let option = Object.assign(mailOptions, options)
|
|
60
|
+
option.html = data
|
|
61
|
+
if (err) {
|
|
62
|
+
console.log(err)
|
|
63
|
+
} else {
|
|
64
|
+
MAIL.send(option)
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
}
|
|
69
68
|
|
|
70
|
-
module.exports = MAIL
|
|
69
|
+
module.exports = MAIL
|