mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-20 20:46:08 +08:00
Allow HTML for custom email bodies (#5635)
This commit is contained in:
@@ -42,6 +42,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"]}`;
|
||||
}
|
||||
@@ -50,11 +51,11 @@ class SMTP extends NotificationProvider {
|
||||
// cannot end with whitespace as this often raises spam scores
|
||||
const customSubject = notification.customSubject?.trim() || "";
|
||||
const customBody = notification.customBody?.trim() || "";
|
||||
|
||||
if (customSubject !== "") {
|
||||
subject = await this.renderTemplate(customSubject, msg, monitorJSON, heartbeatJSON);
|
||||
}
|
||||
if (customBody !== "") {
|
||||
useHTMLBody = notification.htmlBody || false;
|
||||
body = await this.renderTemplate(customBody, msg, monitorJSON, heartbeatJSON);
|
||||
}
|
||||
}
|
||||
@@ -67,7 +68,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;
|
||||
|
Reference in New Issue
Block a user