-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
49 lines (43 loc) · 1.06 KB
/
index.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
var express = require('express');
var CronJob = require('cron').CronJob;
var app = express();
var job = new CronJob('00 00 01 * * 1-7', function() {
/*
* Runs every weekday (Monday through Friday)
* at 11:30:00 AM. It does not run on Saturday
* or Sunday.
*/
SendEmail();
}, function () {
/* This function is executed when the job stops */
},
true, /* Start the job right now */
"Asia/Kolkata" /* Time zone of this job. */
);
function SendEmail(){
var datetime = new Date();
var transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: '[email protected]',
pass: 'prem0690'
}
});
var mailOptions = {
from: '[email protected]',
to: '[email protected]',
subject: 'Sending Email using Node.js',
text: 'I am worked @ 12 Am'+datetime
};
transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});
}
var portNum = 4000;
app.listen(4000, function () {
console.log('Making some pancakes on port:', portNum);
});