isite 2022.8.4 → 2022.8.5

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/email.js ADDED
@@ -0,0 +1,108 @@
1
+ module.exports = function init(____0) {
2
+
3
+ ____0.sendFreeMail = function (mail, callback) {
4
+ callback =
5
+ callback ||
6
+ function (err, res) {
7
+ console.log(err || res);
8
+ };
9
+ if (!mail || !mail.from || !mail.to || !mail.subject || !mail.message) {
10
+ callback({ message: ' Check Mail All Fields [ from , to , subject , message ] ' });
11
+ return;
12
+ }
13
+ mail.source = 'isite';
14
+ mail.from_email = mail.from;
15
+ mail.to_email = mail.to;
16
+
17
+ ____0
18
+ .fetch(`http://emails.egytag.com/api/emails/add`, {
19
+ method: 'POST',
20
+ headers: { 'Content-Type': 'application/json' },
21
+ body: JSON.stringify(mail),
22
+ })
23
+ .then((res) => res.json())
24
+ .then((body) => {
25
+ callback(null, body);
26
+ })
27
+ .catch((err) => {
28
+ callback(err);
29
+ });
30
+ };
31
+
32
+ ____0.sendSmptMail = function (mail, callback) {
33
+ callback =
34
+ callback ||
35
+ function (err, res) {
36
+ console.log(err || res);
37
+ };
38
+ if (!mail || !mail.from || !mail.to || !mail.subject || !mail.message) {
39
+ callback({ message: ' Check Mail All Fields [ from , to , subject , message ] ' });
40
+ return;
41
+ }
42
+ mail = { ...____0.options.mail, ...mail };
43
+ var transporter = ____0.nodemailer.createTransport({
44
+ host: mail.host,
45
+ port: mail.port || 587,
46
+ secure: mail.secure, // true for 465, false for other ports
47
+ auth: {
48
+ user: mail.username, // generated ethereal user
49
+ pass: mail.password, // generated ethereal password
50
+ },
51
+ });
52
+
53
+ var mailOptions = {
54
+ from: mail.from,
55
+ to: mail.to,
56
+ cc: mail.cc,
57
+ bcc: mail.bcc,
58
+ subject: mail.subject,
59
+ html: mail.message,
60
+ text: mail.message.replace(/<[^>]+>/g, ''),
61
+ headers: {
62
+ 'x-lib': 'isite',
63
+ },
64
+ date: new Date(),
65
+ attachments: [{ filename: 'isite.txt', content: 'test attachment', contentType: 'text/plain' }],
66
+ };
67
+
68
+ transporter.sendMail(mailOptions, function (err, info) {
69
+ callback(err, info);
70
+ });
71
+ };
72
+
73
+ ____0.checkMailConfig = function (mail, callback) {
74
+ callback =
75
+ callback ||
76
+ function (err, res) {
77
+ console.log(err || res);
78
+ };
79
+
80
+ mail = { ...____0.options.mail, ...mail };
81
+ var transporter = ____0.nodemailer.createTransport({
82
+ host: mail.host,
83
+ port: mail.port || 587,
84
+ secure: mail.secure, // true for 465, false for other ports
85
+ auth: {
86
+ user: mail.username, // generated ethereal user
87
+ pass: mail.password, // generated ethereal password
88
+ },
89
+ });
90
+
91
+ transporter.verify(function (err, success) {
92
+ callback(err, success);
93
+ });
94
+ };
95
+
96
+ // let transporter = nodemailer.createTransport({
97
+ // host: "smtp.gmail.com",
98
+ // port: 465,
99
+ // secure: true,
100
+ // auth: {
101
+ // type: "OAuth2",
102
+ // user: "user@example.com",
103
+ // accessToken: "ya29.Xx_XX0xxxxx-xX0X0XxXXxXxXXXxX0x",
104
+ // },
105
+ // });
106
+
107
+
108
+ };
package/lib/integrated.js CHANGED
@@ -1,30 +1,14 @@
1
1
  module.exports = function init(____0) {
2
- ____0.sendEmail = function (mail, callback) {
3
- callback =
4
- callback ||
5
- function (err, res) {
6
- console.log(err || res);
7
- };
8
- if (!mail || !mail.from || !mail.to || !mail.subject || !mail.message) {
9
- callback({ message: ' Check Mail All Fields [ from , to , subject , message ] ' });
10
- return;
2
+ ____0.sendEmail =____0.sendMail = function (mail, callback) {
3
+ mail = { ...____0.options.mail, ...mail };
4
+ if (mail.enabled) {
5
+ if (mail.type === 'smpt') {
6
+ ____0.sendSmptMail(mail, callback);
7
+ } else {
8
+ ____0.sendFreeMail(mail, callback);
9
+ }
10
+ } else {
11
+ callback({ message: 'mail not enabled in site options' });
11
12
  }
12
- mail.source = 'isite';
13
- mail.from_email = mail.from;
14
- mail.to_email = mail.to;
15
-
16
- ____0
17
- .fetch(`http://emails.egytag.com/api/emails/add`, {
18
- method: 'POST',
19
- headers: { 'Content-Type': 'application/json' },
20
- body: JSON.stringify(mail),
21
- })
22
- .then((res) => res.json())
23
- .then((body) => {
24
- callback(null, body);
25
- })
26
- .catch((err) => {
27
- callback(err);
28
- });
29
13
  };
30
14
  };