From b0acda52f9b6b47aedb3ce1b05ea78d73c6b7be0 Mon Sep 17 00:00:00 2001 From: Domenic Horner Date: Sat, 4 Sep 2021 11:27:18 +0800 Subject: [PATCH] Add time to smtp body content --- server/notification.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/server/notification.js b/server/notification.js index 520d78dd..beb1ff9d 100644 --- a/server/notification.js +++ b/server/notification.js @@ -94,7 +94,7 @@ class Notification { } } else if (notification.type === "smtp") { - return await Notification.smtp(notification, msg) + return await Notification.smtp(notification, msg, heartbeatJSON) } else if (notification.type === "discord") { try { @@ -648,7 +648,7 @@ class Notification { await R.trash(bean) } - static async smtp(notification, msg) { + static async smtp(notification, msg, heartbeatJSON = null) { const config = { host: notification.smtpHost, @@ -666,12 +666,17 @@ class Notification { let transporter = nodemailer.createTransport(config); + let bodyTextContent = msg; + if(heartbeatJSON) { + bodyTextContent = `${msg}\nTime (UTC): ${heartbeatJSON["time"]}`; + } + // send mail with defined transport object await transporter.sendMail({ from: `"Uptime Kuma" <${notification.smtpFrom}>`, to: notification.smtpTo, subject: msg, - text: msg, + text: bodyTextContent, }); return "Sent Successfully.";