diff --git a/src/Ombi/ClientApp/app/settings/notifications/emailnotification.component.ts b/src/Ombi/ClientApp/app/settings/notifications/emailnotification.component.ts
index 762b6981d..e1db94cae 100644
--- a/src/Ombi/ClientApp/app/settings/notifications/emailnotification.component.ts
+++ b/src/Ombi/ClientApp/app/settings/notifications/emailnotification.component.ts
@@ -72,7 +72,7 @@ export class EmailNotificationComponent implements OnInit {
}
this.testerService.emailTest(form.value).subscribe(x => {
- if (x) {
+ if (x === true) {
this.notificationService.success("Sent", "Successfully sent an email message, please check your inbox");
} else {
this.notificationService.success("Error", "There was an error when sending the Email message, please check your settings.");
diff --git a/src/Ombi/Controllers/External/TesterController.cs b/src/Ombi/Controllers/External/TesterController.cs
index f52bf405d..3fc1b6092 100644
--- a/src/Ombi/Controllers/External/TesterController.cs
+++ b/src/Ombi/Controllers/External/TesterController.cs
@@ -12,8 +12,10 @@ using Ombi.Attributes;
using Ombi.Core.Notifications;
using Ombi.Core.Settings.Models.External;
using Ombi.Helpers;
+using Ombi.Notifications;
using Ombi.Notifications.Agents;
using Ombi.Notifications.Models;
+using Ombi.Notifications.Templates;
using Ombi.Settings.Settings.Models.External;
using Ombi.Settings.Settings.Models.Notifications;
@@ -44,7 +46,7 @@ namespace Ombi.Controllers.External
/// The logger.
public TesterController(INotificationService service, IDiscordNotification notification, IEmailNotification emailN,
IPushbulletNotification pushbullet, ISlackNotification slack, IPushoverNotification po, IMattermostNotification mm,
- IPlexApi plex, IEmbyApi emby, IRadarrApi radarr, ISonarrApi sonarr, ILogger log)
+ IPlexApi plex, IEmbyApi emby, IRadarrApi radarr, ISonarrApi sonarr, ILogger log, IEmailProvider provider)
{
Service = service;
DiscordNotification = notification;
@@ -58,6 +60,7 @@ namespace Ombi.Controllers.External
EmbyApi = emby;
SonarrApi = sonarr;
Log = log;
+ EmailProvider = provider;
}
private INotificationService Service { get; }
@@ -72,6 +75,7 @@ namespace Ombi.Controllers.External
private IEmbyApi EmbyApi { get; }
private ISonarrApi SonarrApi { get; }
private ILogger Log { get; }
+ private IEmailProvider EmailProvider { get; }
///
@@ -156,15 +160,25 @@ namespace Ombi.Controllers.External
/// The settings.
///
[HttpPost("email")]
- public bool Email([FromBody] EmailNotificationSettings settings)
+ public async Task Email([FromBody] EmailNotificationSettings settings)
{
- settings.Enabled = true;
- var notificationModel = new NotificationOptions
+ try
{
- NotificationType = NotificationType.Test,
- RequestId = -1
- };
- EmailNotification.NotifyAsync(notificationModel, settings);
+ var message = new NotificationMessage
+ {
+ Message = "This is just a test! Success!",
+ Subject = $"Ombi: Test",
+ To = settings.AdminEmail,
+ };
+
+ message.Other.Add("PlainTextBody", "This is just a test! Success!");
+ await EmailProvider.SendAdHoc(message, settings);
+ }
+ catch (Exception e)
+ {
+ Log.LogWarning(e, "Exception when testing Email Notifications");
+ return false;
+ }
return true;
}