From f3bbddc287c7157061230564ebebe51ee86be6b5 Mon Sep 17 00:00:00 2001 From: Martijn Smit Date: Mon, 29 Sep 2025 14:11:57 +0200 Subject: [PATCH] feat: Add Brevo notification provider (#6150) Co-authored-by: Frank Elsinga --- server/notification-providers/brevo.js | 62 ++++++++++++++++++++++++++ server/notification.js | 2 + src/components/NotificationDialog.vue | 1 + src/components/notifications/Brevo.vue | 58 ++++++++++++++++++++++++ src/components/notifications/index.js | 2 + src/lang/en.json | 11 +++++ 6 files changed, 136 insertions(+) create mode 100644 server/notification-providers/brevo.js create mode 100644 src/components/notifications/Brevo.vue diff --git a/server/notification-providers/brevo.js b/server/notification-providers/brevo.js new file mode 100644 index 000000000..b896f81c3 --- /dev/null +++ b/server/notification-providers/brevo.js @@ -0,0 +1,62 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); + +class Brevo extends NotificationProvider { + name = "Brevo"; + + /** + * @inheritdoc + */ + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + const okMsg = "Sent Successfully."; + + try { + let config = { + headers: { + "Accept": "application/json", + "Content-Type": "application/json", + "api-key": notification.brevoApiKey, + }, + }; + + let to = [{ email: notification.brevoToEmail }]; + + let data = { + sender: { + email: notification.brevoFromEmail.trim(), + name: notification.brevoFromName || "Uptime Kuma" + }, + to: to, + subject: notification.brevoSubject || "Notification from Your Uptime Kuma", + htmlContent: `

${msg.replace(/\n/g, "
")}

` + }; + + if (notification.brevoCcEmail) { + data.cc = notification.brevoCcEmail + .split(",") + .map((email) => ({ email: email.trim() })); + } + + if (notification.brevoBccEmail) { + data.bcc = notification.brevoBccEmail + .split(",") + .map((email) => ({ email: email.trim() })); + } + + let result = await axios.post( + "https://api.brevo.com/v3/smtp/email", + data, + config + ); + if (result.status === 201) { + return okMsg; + } else { + throw new Error(`Unexpected status code: ${result.status}`); + } + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = Brevo; diff --git a/server/notification.js b/server/notification.js index 36bfdfc29..d0c8c740a 100644 --- a/server/notification.js +++ b/server/notification.js @@ -75,6 +75,7 @@ const Cellsynt = require("./notification-providers/cellsynt"); const Onesender = require("./notification-providers/onesender"); const Wpush = require("./notification-providers/wpush"); const SendGrid = require("./notification-providers/send-grid"); +const Brevo = require("./notification-providers/brevo"); const YZJ = require("./notification-providers/yzj"); const SMSPlanet = require("./notification-providers/sms-planet"); const SpugPush = require("./notification-providers/spugpush"); @@ -169,6 +170,7 @@ class Notification { new Cellsynt(), new Wpush(), new SendGrid(), + new Brevo(), new YZJ(), new SMSPlanet(), new SpugPush(), diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index b9b2b65d2..09e554634 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -170,6 +170,7 @@ export default { "gtxmessaging": "GtxMessaging", "Cellsynt": "Cellsynt", "SendGrid": "SendGrid", + "Brevo": "Brevo", "notifery": "Notifery" }; diff --git a/src/components/notifications/Brevo.vue b/src/components/notifications/Brevo.vue new file mode 100644 index 000000000..5908486d0 --- /dev/null +++ b/src/components/notifications/Brevo.vue @@ -0,0 +1,58 @@ + + + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 300bbc755..c20d57818 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -74,6 +74,7 @@ import Cellsynt from "./Cellsynt.vue"; import WPush from "./WPush.vue"; import SIGNL4 from "./SIGNL4.vue"; import SendGrid from "./SendGrid.vue"; +import Brevo from "./Brevo.vue"; import YZJ from "./YZJ.vue"; import SMSPlanet from "./SMSPlanet.vue"; @@ -158,6 +159,7 @@ const NotificationFormList = { "Cellsynt": Cellsynt, "WPush": WPush, "SendGrid": SendGrid, + "Brevo": Brevo, "YZJ": YZJ, "SMSPlanet": SMSPlanet, }; diff --git a/src/lang/en.json b/src/lang/en.json index 2f5249fe8..54b5003a0 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -1100,6 +1100,17 @@ "rabbitmqHelpText": "To use the monitor, you will need to enable the Management Plugin in your RabbitMQ setup. For more information, please consult the {rabitmq_documentation}.", "SendGrid API Key": "SendGrid API Key", "Separate multiple email addresses with commas": "Separate multiple email addresses with commas", + "brevoApiKey": "Brevo API Key", + "brevoApiHelp": "Create an API key here: {0}", + "brevoFromEmail": "From Email", + "brevoFromName": "From Name", + "brevoLeaveBlankForDefaultName": "leave blank for default name", + "brevoToEmail": "To Email", + "brevoCcEmail": "CC Email", + "brevoBccEmail": "BCC Email", + "brevoSeparateMultipleEmails": "Separate multiple email addresses with commas", + "brevoSubject": "Subject", + "brevoLeaveBlankForDefaultSubject": "leave blank for default subject", "pingCountLabel": "Max Packets", "pingCountDescription": "Number of packets to send before stopping", "pingNumericLabel": "Numeric Output",