From acb99487f853f99b170ec44bcc00afc161215480 Mon Sep 17 00:00:00 2001 From: youpie Date: Wed, 19 Feb 2025 23:37:13 +0100 Subject: [PATCH 1/6] changed smtp to allow for html bodies --- server/notification-providers/smtp.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/notification-providers/smtp.js b/server/notification-providers/smtp.js index 9f3defa5e..35d714f0c 100644 --- a/server/notification-providers/smtp.js +++ b/server/notification-providers/smtp.js @@ -44,6 +44,7 @@ class SMTP extends NotificationProvider { // default values in case the user does not want to template let subject = msg; let body = msg; + let use_html_body = false if (heartbeatJSON) { body = `${msg}\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`; } @@ -52,7 +53,7 @@ class SMTP extends NotificationProvider { // cannot end with whitespace as this often raises spam scores const customSubject = notification.customSubject?.trim() || ""; const customBody = notification.customBody?.trim() || ""; - + use_html_body = notification.htmlBody || false const context = this.generateContext(msg, monitorJSON, heartbeatJSON); const engine = new Liquid(); if (customSubject !== "") { @@ -73,7 +74,7 @@ class SMTP extends NotificationProvider { bcc: notification.smtpBCC, to: notification.smtpTo, subject: subject, - text: body, + [htmlBody ? 'html' : 'text']: body }); return okMsg; From 59ec067d632161d2f996c873927b2fbd3b857470 Mon Sep 17 00:00:00 2001 From: youpie Date: Wed, 19 Feb 2025 23:40:24 +0100 Subject: [PATCH 2/6] updated vue --- src/components/notifications/SMTP.vue | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/components/notifications/SMTP.vue b/src/components/notifications/SMTP.vue index 003f90556..3e2da9bce 100644 --- a/src/components/notifications/SMTP.vue +++ b/src/components/notifications/SMTP.vue @@ -89,6 +89,15 @@
{{ $t("leave blank for default body") }}
+
+
+ + +
+
+ {{ $t("documentation") }} From c72adaf58597b7214fb8104e6d21cdb7d98fdd3a Mon Sep 17 00:00:00 2001 From: youpie Date: Wed, 19 Feb 2025 23:52:12 +0100 Subject: [PATCH 3/6] small bug fix --- server/notification-providers/smtp.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/notification-providers/smtp.js b/server/notification-providers/smtp.js index 35d714f0c..76805f1c2 100644 --- a/server/notification-providers/smtp.js +++ b/server/notification-providers/smtp.js @@ -74,7 +74,7 @@ class SMTP extends NotificationProvider { bcc: notification.smtpBCC, to: notification.smtpTo, subject: subject, - [htmlBody ? 'html' : 'text']: body + [use_html_body ? 'html' : 'text']: body }); return okMsg; From 3fa33c87d9ba5aecf7c32c4f16d64084a850cccc Mon Sep 17 00:00:00 2001 From: youpie Date: Wed, 19 Feb 2025 23:56:28 +0100 Subject: [PATCH 4/6] only apply html for custom bodies --- server/notification-providers/smtp.js | 2 +- src/components/notifications/SMTP.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/notification-providers/smtp.js b/server/notification-providers/smtp.js index 76805f1c2..e7f86f014 100644 --- a/server/notification-providers/smtp.js +++ b/server/notification-providers/smtp.js @@ -53,7 +53,6 @@ class SMTP extends NotificationProvider { // cannot end with whitespace as this often raises spam scores const customSubject = notification.customSubject?.trim() || ""; const customBody = notification.customBody?.trim() || ""; - use_html_body = notification.htmlBody || false const context = this.generateContext(msg, monitorJSON, heartbeatJSON); const engine = new Liquid(); if (customSubject !== "") { @@ -61,6 +60,7 @@ class SMTP extends NotificationProvider { subject = await engine.render(tpl, context); } if (customBody !== "") { + use_html_body = notification.htmlBody || false const tpl = engine.parse(customBody); body = await engine.render(tpl, context); } diff --git a/src/components/notifications/SMTP.vue b/src/components/notifications/SMTP.vue index 3e2da9bce..4da2bd0f0 100644 --- a/src/components/notifications/SMTP.vue +++ b/src/components/notifications/SMTP.vue @@ -93,7 +93,7 @@
From 23942f79a8252355cdd1d00ef2bf8a3b93172aca Mon Sep 17 00:00:00 2001 From: youpie Date: Thu, 20 Feb 2025 00:00:33 +0100 Subject: [PATCH 5/6] eslint --- server/notification-providers/smtp.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/notification-providers/smtp.js b/server/notification-providers/smtp.js index e7f86f014..f0d0ad8da 100644 --- a/server/notification-providers/smtp.js +++ b/server/notification-providers/smtp.js @@ -44,7 +44,7 @@ class SMTP extends NotificationProvider { // default values in case the user does not want to template let subject = msg; let body = msg; - let use_html_body = false + let useHTMLBody = false; if (heartbeatJSON) { body = `${msg}\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`; } @@ -60,7 +60,7 @@ class SMTP extends NotificationProvider { subject = await engine.render(tpl, context); } if (customBody !== "") { - use_html_body = notification.htmlBody || false + useHTMLBody = notification.htmlBody || false; const tpl = engine.parse(customBody); body = await engine.render(tpl, context); } @@ -74,7 +74,7 @@ class SMTP extends NotificationProvider { bcc: notification.smtpBCC, to: notification.smtpTo, subject: subject, - [use_html_body ? 'html' : 'text']: body + [useHTMLBody ? "html" : "text"]: body }); return okMsg; From f7f224bc34adc2d4e6759208f231b4c5ac0291ef Mon Sep 17 00:00:00 2001 From: youpie Date: Thu, 20 Feb 2025 00:02:00 +0100 Subject: [PATCH 6/6] small comment --- server/notification-providers/smtp.js | 1 + 1 file changed, 1 insertion(+) diff --git a/server/notification-providers/smtp.js b/server/notification-providers/smtp.js index f0d0ad8da..6f6064943 100644 --- a/server/notification-providers/smtp.js +++ b/server/notification-providers/smtp.js @@ -74,6 +74,7 @@ class SMTP extends NotificationProvider { bcc: notification.smtpBCC, to: notification.smtpTo, subject: subject, + // If the email body is custom, and the user wants it, set the email body as HTML [useHTMLBody ? "html" : "text"]: body });