From 2d016315c7a910994f99d9f9ecd243f8ba3e36db Mon Sep 17 00:00:00 2001 From: tidusjar Date: Thu, 24 Mar 2016 11:31:49 +0000 Subject: [PATCH] Added the ability to sepcify a username in the email notification settings for external MTA's. We have had to add a new option called Email Sender because of this. #78 --- .../SettingModels/EmailNotificationSettings.cs | 1 + .../Notification/EmailMessageNotification.cs | 4 ++-- .../Validators/EmailNotificationSettingsValidator.cs | 3 ++- PlexRequests.UI/Views/Admin/EmailNotifications.cshtml | 8 ++++++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/PlexRequests.Core/SettingModels/EmailNotificationSettings.cs b/PlexRequests.Core/SettingModels/EmailNotificationSettings.cs index e725b0f0c..6a151e861 100644 --- a/PlexRequests.Core/SettingModels/EmailNotificationSettings.cs +++ b/PlexRequests.Core/SettingModels/EmailNotificationSettings.cs @@ -6,6 +6,7 @@ public int EmailPort { get; set; } public bool Ssl { get; set; } public string RecipientEmail { get; set; } + public string EmailSender { get; set; } public string EmailUsername { get; set; } public string EmailPassword { get; set; } public bool Enabled { get; set; } diff --git a/PlexRequests.Services/Notification/EmailMessageNotification.cs b/PlexRequests.Services/Notification/EmailMessageNotification.cs index 43d567cd8..db6bc24b2 100644 --- a/PlexRequests.Services/Notification/EmailMessageNotification.cs +++ b/PlexRequests.Services/Notification/EmailMessageNotification.cs @@ -101,7 +101,7 @@ namespace PlexRequests.Services.Notification IsBodyHtml = true, To = { new MailAddress(Settings.RecipientEmail) }, Body = $"Hello! The user '{model.User}' has requested {model.Title}! Please log in to approve this request. Request Date: {model.DateTime.ToString("f")}", - From = new MailAddress(Settings.EmailUsername), + From = new MailAddress(Settings.EmailSender), Subject = $"Plex Requests: New request for {model.Title}!" }; @@ -133,7 +133,7 @@ namespace PlexRequests.Services.Notification IsBodyHtml = true, To = { new MailAddress(Settings.RecipientEmail) }, Body = $"Hello! The user '{model.User}' has reported a new issue {model.Body} for the title {model.Title}!", - From = new MailAddress(Settings.EmailUsername), + From = new MailAddress(Settings.RecipientEmail), Subject = $"Plex Requests: New issue for {model.Title}!" }; diff --git a/PlexRequests.UI/Validators/EmailNotificationSettingsValidator.cs b/PlexRequests.UI/Validators/EmailNotificationSettingsValidator.cs index be5c106e7..ddf4a5268 100644 --- a/PlexRequests.UI/Validators/EmailNotificationSettingsValidator.cs +++ b/PlexRequests.UI/Validators/EmailNotificationSettingsValidator.cs @@ -38,9 +38,10 @@ namespace PlexRequests.UI.Validators RuleFor(request => request.EmailPort).NotEmpty().WithMessage("You must specify a Port."); RuleFor(request => request.RecipientEmail).NotEmpty().WithMessage("You must specify a Recipient."); RuleFor(request => request.RecipientEmail).EmailAddress().WithMessage("You must specify a valid Recipient."); - RuleFor(request => request.EmailUsername).EmailAddress().WithMessage("You must specify a valid Username."); RuleFor(request => request.EmailUsername).NotEmpty().WithMessage("You must specify a Username."); RuleFor(request => request.EmailPassword).NotEmpty().WithMessage("You must specify a valid password."); + RuleFor(request => request.EmailSender).EmailAddress().WithMessage("You must specify a valid Email for the email sender."); + RuleFor(request => request.EmailSender).NotEmpty().WithMessage("You must specify a Email Sender."); } } } \ No newline at end of file diff --git a/PlexRequests.UI/Views/Admin/EmailNotifications.cshtml b/PlexRequests.UI/Views/Admin/EmailNotifications.cshtml index 6e0543aea..41a667e51 100644 --- a/PlexRequests.UI/Views/Admin/EmailNotifications.cshtml +++ b/PlexRequests.UI/Views/Admin/EmailNotifications.cshtml @@ -59,6 +59,12 @@ +
+ +
+ +
+
@@ -66,6 +72,8 @@
+ +