-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
38 lines (32 loc) · 969 Bytes
/
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
const cron = require ('node-cron')
const express = require('express')
const nodemailer = require('nodemailer')
app = express()
let transporter = nodemailer.createTransport({
host: "your_test_email_smtp_host",
port: "your_test_email_port" ,
auth: {
user: "your_test_email",
pass: "your_test_email_password"
},
});
// Sending emails every Monday.
//more help on crontab.tech
cron.schedule('0 0 * * 1', function() {
console.log('--------Running Email Cron Job-------------');
console.log('Sending email...');
let messageOptions = {
from: 'your_test_email_address',
to: '[email protected]',
subject: 'Test Email Subject',
text: 'Test message message'
};
transporter.sendMail(messageOptions, function(error, info) {
if (error) {
throw error;
} else {
console.log('Scheduled Email has been successfully sent');
}
});
});
app.listen(4000)