diff --git a/server/notification-providers/smtp.js b/server/notification-providers/smtp.js index 9f3defa5e..6f6064943 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 useHTMLBody = false; if (heartbeatJSON) { body = `${msg}\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`; } @@ -52,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() || ""; - const context = this.generateContext(msg, monitorJSON, heartbeatJSON); const engine = new Liquid(); if (customSubject !== "") { @@ -60,6 +60,7 @@ class SMTP extends NotificationProvider { subject = await engine.render(tpl, context); } if (customBody !== "") { + useHTMLBody = notification.htmlBody || false; const tpl = engine.parse(customBody); body = await engine.render(tpl, context); } @@ -73,7 +74,8 @@ class SMTP extends NotificationProvider { bcc: notification.smtpBCC, to: notification.smtpTo, subject: subject, - text: body, + // If the email body is custom, and the user wants it, set the email body as HTML + [useHTMLBody ? "html" : "text"]: body }); return okMsg; diff --git a/src/components/notifications/SMTP.vue b/src/components/notifications/SMTP.vue index 003f90556..4da2bd0f0 100644 --- a/src/components/notifications/SMTP.vue +++ b/src/components/notifications/SMTP.vue @@ -89,6 +89,15 @@