-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsendmail.js
112 lines (105 loc) · 3.61 KB
/
sendmail.js
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
require('dotenv').config();
const nodemailer = require('nodemailer');
const xoauth2 = require('xoauth2');
const { transporter } = require('./transporter');
var jsdom = require('jsdom');
const { JSDOM } = jsdom;
const { window } = new JSDOM();
const { document } = new JSDOM('').window;
global.document = document;
var $ = (jQuery = require('jquery')(window));
/* var transporter = nodemailer.createTransport({
host: 'smtp.gmail.com',
port: 465,
secure: true,
auth: {
type: 'OAuth2',
user: process.env.USER,
clientId: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET,
refreshToken: process.env.REFRESH_TOKEN,
accessToken: process.env.ACCESS_TOKEN,
},
}); */
// For todays date;
Date.prototype.today = function () {
return (
(this.getDate() < 10 ? '0' : '') +
this.getDate() +
'/' +
(this.getMonth() + 1 < 10 ? '0' : '') +
(this.getMonth() + 1) +
'/' +
this.getFullYear()
);
};
// For the time now
Date.prototype.timeNow = function () {
return (
(this.getHours() < 10 ? '0' : '') +
this.getHours() +
':' +
(this.getMinutes() < 10 ? '0' : '') +
this.getMinutes() +
':' +
(this.getSeconds() < 10 ? '0' : '') +
this.getSeconds()
);
};
var datetime = new Date().today() + ' @' + new Date().timeNow();
var devBuild =
(process.env.NODE_ENV || 'development').trim().toLowerCase() !==
'production',
source = './',
dest = devBuild ? 'builds/development/' : 'builds/production/';
var htmlPaths = [
// dest + 'emails/one/template-one.html',
// dest + 'emails/two/template-two.html',
// dest + 'emails/three/template-three.html',
// dest + 'emails/four/template-four.html',
// dest + 'emails/five/template-five.html',
// dest + 'emails/six/template-six.html',
// dest + 'emails/seven/template-seven.html',
// dest + 'emails/eight/template-eight.html',
// dest + 'emails/nine/template-nine.html',
// dest + 'emails/ten/template-ten.html',
// dest + 'emails/eleven/template-eleven.html',
// dest + 'emails/twelve/template-twelve.html',
// dest + 'emails/thirteen/template-thirteen.html',
// dest + 'emails/fourteen/template-fourteen.html',
// dest + 'emails/fifteen/template-fifteen.html',
// dest + 'emails/sixteen/template-sixteen.html',
// dest + 'emails/17/template-17.html',
// dest + 'emails/gmailIssues/clip-off-issue.html',
// dest + 'emails/gmailIssues/23-06-2020/CHARLOTTE INNO ONE BLOCK TEMPLATE.html',
// dest + 'emails/gmailIssues/23-06-2020/CHARLOTTE INNO ONE BLOCK TEMPLATE_Updated.html',
dest + 'emails/19/template-19.html',
],
path,
mailOptions;
$(htmlPaths).each(function (i) {
path = htmlPaths[i];
mailOptions = {
from: 'Kathirr007 <[email protected]>',
to: '[email protected], \
subject: `Test Mail ${i + 1} on ${datetime}`,
text: 'Hello World!!',
html: { path: '' + path + '' },
// html: {path:'https://ep-test.contentplace.io/webapp-theme/fo/mail-intern-info.html'}
};
transporter.sendMail(mailOptions, function (err, res) {
if (err) {
console.log(err);
} else {
console.log(`Email ${i + 1} has been sent Successfully`);
}
});
});
// for (i=0; i<htmlPaths.length; i++){
// }