diff --git a/server/notification-providers/smtp.js b/server/notification-providers/smtp.js index e5fd53e4..2bbec584 100644 --- a/server/notification-providers/smtp.js +++ b/server/notification-providers/smtp.js @@ -22,10 +22,40 @@ class SMTP extends NotificationProvider { } // Lets start with default subject let subject = msg; + // Our subject cannot end with whitespace it's often raise spam score let customsubject = notification.customsubject.trim() + // If custom subject is not empty, change subject for notification if (customsubject !== "") { + + // Replace "MACROS" with coresponding variable + let replaceName = new RegExp("{NAME}", "g"); + let replaceHostname = new RegExp("{HOSTNAME}", "g"); + let replaceStatus = new RegExp("{STATUS}", "g"); + + let serviceStatus; + + if (monitorJSON !== null) { + customsubject = customsubject.replace(replaceName,monitorJSON["name"]); + customsubject = customsubject.replace(replaceHostname,monitorJSON["hostname"]); + } else { + // Insert dummy values during test + customsubject = customsubject.replace(replaceName,"Test"); + customsubject = customsubject.replace(replaceHostname,"example.com"); + } + if (heartbeatJSON !== null) { + if (heartbeatJSON["status"] === 0) { + serviceStatus = "🔴 Down" + } else { + serviceStatus = "✅ Up" + } + customsubject = customsubject.replace(replaceStatus,serviceStatus); + } else { + // Insert dummy values during test + customsubject = customsubject.replace(replaceStatus,"TEST"); + } + subject = customsubject } diff --git a/src/components/notifications/SMTP.vue b/src/components/notifications/SMTP.vue index 165d39c6..01bdf860 100644 --- a/src/components/notifications/SMTP.vue +++ b/src/components/notifications/SMTP.vue @@ -44,8 +44,8 @@
- - + +
diff --git a/src/languages/en.js b/src/languages/en.js index b59cdb73..0e8e9230 100644 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -201,7 +201,7 @@ export default { secureOptionTLS: "TLS (465)", "Ignore TLS Error": "Ignore TLS Error", "From Email": "From Email", - "Custom Email subject": "Custom Email Subject (leave blank for default one)", + "Email Subject": "Subject (leave blank for default one)", "To Email": "To Email", smtpCC: "CC", smtpBCC: "BCC",