-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
37 lines (33 loc) · 756 Bytes
/
index.js
File metadata and controls
37 lines (33 loc) · 756 Bytes
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
const express = require("express");
const app = express();
const cron = require("node-cron");
const mailer = require("nodemailer");
cron.schedule("*/5 * * * * *", function () {
sendEmail("test");
});
function sendEmail(message) {
const transporter = mailer.createTransport({
host: "smtp.gmail.com",
port: 465,
secure: true,
auth: {
user: "user_email",
pass: "less_secure_app_pass",
},
});
transporter
.sendMail({
from: 'sender_email',
to: 'receiver_email',
text: message,
})
.then((_) => {
console.log("Email sent on " + new Date());
})
.catch((error) => {
console.log(error);
});
}
app.listen(2400, () => {
console.log("Server started at port 2400");
});