mirror of
https://github.com/louislam/uptime-kuma.git
synced 2026-08-07 10:14:59 +00:00
feat: add TurboSMTP email notification provider (#7640)
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
const NotificationProvider = require("./notification-provider");
|
||||
const axios = require("axios");
|
||||
|
||||
class TurboSMTP extends NotificationProvider {
|
||||
name = "TurboSMTP";
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||
const okMsg = "Sent Successfully.";
|
||||
|
||||
try {
|
||||
let config = {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
consumerKey: notification.turbosmtpConsumerKey,
|
||||
consumerSecret: notification.turbosmtpConsumerSecret,
|
||||
},
|
||||
};
|
||||
config = this.getAxiosConfigWithProxy(config);
|
||||
|
||||
const host = notification.turbosmtpRegion === "eu" ? "api.eu.turbo-smtp.com" : "api.turbo-smtp.com";
|
||||
|
||||
let data = {
|
||||
from: notification.turbosmtpFromEmail.trim(),
|
||||
to: notification.turbosmtpToEmail,
|
||||
subject: notification.turbosmtpSubject || "Notification from Your Uptime Kuma",
|
||||
content: msg,
|
||||
};
|
||||
|
||||
// Comma-separated lists, same format as "to"
|
||||
if (notification.turbosmtpCcEmail) {
|
||||
data.cc = notification.turbosmtpCcEmail
|
||||
.split(",")
|
||||
.map((email) => email.trim())
|
||||
.join(",");
|
||||
}
|
||||
|
||||
if (notification.turbosmtpBccEmail) {
|
||||
data.bcc = notification.turbosmtpBccEmail
|
||||
.split(",")
|
||||
.map((email) => email.trim())
|
||||
.join(",");
|
||||
}
|
||||
|
||||
await axios.post(`https://${host}/api/v2/mail/send`, data, config);
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
this.throwGeneralAxiosError(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TurboSMTP;
|
||||
@@ -88,6 +88,7 @@ const Onesender = require("./notification-providers/onesender");
|
||||
const Wpush = require("./notification-providers/wpush");
|
||||
const WxPusher = require("./notification-providers/wxpusher");
|
||||
const SendGrid = require("./notification-providers/send-grid");
|
||||
const TurboSMTP = require("./notification-providers/turbosmtp");
|
||||
const Brevo = require("./notification-providers/brevo");
|
||||
const Resend = require("./notification-providers/resend");
|
||||
const YZJ = require("./notification-providers/yzj");
|
||||
@@ -211,6 +212,7 @@ class Notification {
|
||||
new Notifery(),
|
||||
new SMSIR(),
|
||||
new SendGrid(),
|
||||
new TurboSMTP(),
|
||||
new Whatsapp360messenger(),
|
||||
new Webpush(),
|
||||
new HaloPSA(),
|
||||
|
||||
Reference in New Issue
Block a user