diff --git a/server/controllers/notificationController.js b/server/controllers/notificationController.js index edb18adfb..df16f7a75 100755 --- a/server/controllers/notificationController.js +++ b/server/controllers/notificationController.js @@ -90,7 +90,7 @@ class NotificationController { const notification = req.body; if (notification?.type === "email") { - console.log("HANDLE EMAIL"); + const result = await this.notificationService.sendTestEmail(notification); return res.success({ msg: this.stringService.emailSendSuccess, }); diff --git a/server/service/notificationService.js b/server/service/notificationService.js index 56c6d2c1c..30c8474c1 100755 --- a/server/service/notificationService.js +++ b/server/service/notificationService.js @@ -196,6 +196,24 @@ class NotificationService { return true; } + sendTestEmail = async (notification) => { + const to = notification?.address; + if (!to || typeof to !== "string") { + throw new Error(this.stringService.errorForValidEmailAddress); + } + + const subject = this.stringService.testEmailSubject; + const context = { testName: "Monitoring System" }; + + const messageId = await this.emailService.buildAndSendEmail( + "testEmailTemplate", + context, + to, + subject + ); + console.log(messageId); + }; + /** * Sends an email notification about monitor status change *