-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcron.js
44 lines (39 loc) · 1.23 KB
/
cron.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
import nodemailer from "nodemailer";
async function sendMail(toMail, sub, textBody) {
// create reusable transporter object using the default SMTP transport
let transporter = nodemailer.createTransport({
service: "gmail",
host: "smtp.gmail.com",
port: 465,
secure: true,
auth: {
user: import.meta.env.SMTP_USER,
pass: import.meta.env.SMTP_PASSWORD,
},
});
// send mail with defined transport object
let info = await transporter.sendMail({
from: '"Prannay Kedia" <[email protected]>', // sender address
to: toMail, // list of receivers
subject: sub, // Subject line
text: textBody, // plain text body
});
console.log("Message sent: %s", info.messageId);
}
export default function handler(req, res) {
fetch(
"https://www.google.com/ping?sitemap=https://prannaykedia.com/sitemap-index.xml"
)
.then((response) => response.json())
.then(async (data) => {
await sendMail(
"Sitemap Submitted for Prannay Kedia",
"Sitemap updation request submitted to Google at : " + Date.now()
).catch(console.error);
})
.catch((error) => {
console.error(error);
});
res.status(200).end("Hello Cron!");
}