diff --git a/Ombi.Core/Ombi.Core.csproj b/Ombi.Core/Ombi.Core.csproj
index 9866e6fb0..f6562c2fc 100644
--- a/Ombi.Core/Ombi.Core.csproj
+++ b/Ombi.Core/Ombi.Core.csproj
@@ -124,6 +124,7 @@
+
diff --git a/Ombi.Core/SettingModels/MassEmailSettings.cs b/Ombi.Core/SettingModels/MassEmailSettings.cs
new file mode 100644
index 000000000..0be28a92d
--- /dev/null
+++ b/Ombi.Core/SettingModels/MassEmailSettings.cs
@@ -0,0 +1,35 @@
+#region Copyright
+// /************************************************************************
+// Copyright (c) 2016 Jamie Rees
+// File: EmailNotificationSettings.cs
+// Created By: Jamie Rees
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// ************************************************************************/
+#endregion
+namespace Ombi.Core.SettingModels
+{
+ public sealed class MassEmailSettings : NotificationSettings
+ {
+ public string Users { get; set; }
+ public string Subject { get; set; }
+ public string Body { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Ombi.Services/Interfaces/IMassEmail.cs b/Ombi.Services/Interfaces/IMassEmail.cs
index c7b88cad9..9751cc870 100644
--- a/Ombi.Services/Interfaces/IMassEmail.cs
+++ b/Ombi.Services/Interfaces/IMassEmail.cs
@@ -5,6 +5,8 @@ namespace Ombi.Services.Jobs
public interface IMassEmail
{
void Execute(IJobExecutionContext context);
- void MassEmailAdminTest(string html);
+ void MassEmailAdminTest(string html, string subject);
+ void SendMassEmail(string html, string subject);
+
}
}
\ No newline at end of file
diff --git a/Ombi.Services/Jobs/RecentlyAdded.cs b/Ombi.Services/Jobs/RecentlyAdded.cs
index 937eac8ab..9ee52f231 100644
--- a/Ombi.Services/Jobs/RecentlyAdded.cs
+++ b/Ombi.Services/Jobs/RecentlyAdded.cs
@@ -111,14 +111,23 @@ namespace Ombi.Services.Jobs
var settings = NewsletterSettings.GetSettings();
Start(settings, true);
}
- public void MassEmailAdminTest(string html)
+ public void MassEmailAdminTest(string html, string subject)
{
Log.Debug("Starting Mass Email Test");
var settings = NewsletterSettings.GetSettings();
var plexSettings = PlexSettings.GetSettings();
var template = new MassEmailTemplate();
var body = template.LoadTemplate(html);
- Send(settings, body, plexSettings, true);
+ Send(settings, body, plexSettings, true, subject);
+ }
+ public void SendMassEmail(string html, string subject)
+ {
+ Log.Debug("Starting Mass Email Test");
+ var settings = NewsletterSettings.GetSettings();
+ var plexSettings = PlexSettings.GetSettings();
+ var template = new MassEmailTemplate();
+ var body = template.LoadTemplate(html);
+ Send(settings, body, plexSettings, false, subject);
}
private void Start(NewletterSettings newletterSettings, bool testEmail = false)
@@ -448,7 +457,7 @@ namespace Ombi.Services.Jobs
sb.Append("
");
}
- private void Send(NewletterSettings newletterSettings, string html, PlexSettings plexSettings, bool testEmail = false)
+ private void Send(NewletterSettings newletterSettings, string html, PlexSettings plexSettings, bool testEmail = false, string subject = "New Content on Plex!")
{
Log.Debug("Entering Send");
var settings = EmailSettings.GetSettings();
@@ -463,7 +472,7 @@ namespace Ombi.Services.Jobs
var message = new MimeMessage
{
Body = body.ToMessageBody(),
- Subject = "New Content on Plex!",
+ Subject = subject
};
Log.Debug("Created Plain/HTML MIME body");
diff --git a/Ombi.Services/Jobs/Templates/MassEmailTemplate.html b/Ombi.Services/Jobs/Templates/MassEmailTemplate.html
index 4fdd04524..02214c6af 100644
--- a/Ombi.Services/Jobs/Templates/MassEmailTemplate.html
+++ b/Ombi.Services/Jobs/Templates/MassEmailTemplate.html
@@ -148,7 +148,7 @@
-
+ |
{@MASSEMAIL}
|
diff --git a/Ombi.UI/Modules/Admin/AdminModule.cs b/Ombi.UI/Modules/Admin/AdminModule.cs
index 181cc1d1b..a0b6216f7 100644
--- a/Ombi.UI/Modules/Admin/AdminModule.cs
+++ b/Ombi.UI/Modules/Admin/AdminModule.cs
@@ -1252,8 +1252,16 @@ namespace Ombi.UI.Modules.Admin
{
try
{
+ var settings = this.Bind();
Log.Debug("Clicked Admin Mass Email Test");
- MassEmail.MassEmailAdminTest("Dhruv's Test Email");
+ if (settings.Subject == null) {
+ return Response.AsJson(new JsonResponseModel { Result = false, Message = "Please Set a Subject" });
+ }
+ if (settings.Body == null)
+ {
+ return Response.AsJson(new JsonResponseModel { Result = false, Message = "Please Set a Body" });
+ }
+ MassEmail.MassEmailAdminTest(settings.Body.Replace("\n", "
"), settings.Subject);
return Response.AsJson(new JsonResponseModel { Result = true, Message = "Sent email to administrator" });
}
catch (Exception e)
@@ -1266,9 +1274,18 @@ namespace Ombi.UI.Modules.Admin
{
try
{
- Log.Debug("Clicked Send Mass Email");
- RecentlyAdded.RecentlyAddedAdminTest();
- return Response.AsJson(new JsonResponseModel { Result = true, Message = "Sent email to administrator" });
+ var settings = this.Bind();
+ Log.Debug("Clicked Admin Mass Email Test");
+ if (settings.Subject == null)
+ {
+ return Response.AsJson(new JsonResponseModel { Result = false, Message = "Please Set a Subject" });
+ }
+ if (settings.Body == null)
+ {
+ return Response.AsJson(new JsonResponseModel { Result = false, Message = "Please Set a Body" });
+ }
+ MassEmail.SendMassEmail(settings.Body.Replace("\n", "
"), settings.Subject);
+ return Response.AsJson(new JsonResponseModel { Result = true, Message = "Sent email to All users" });
}
catch (Exception e)
{
diff --git a/Ombi.UI/Views/Admin/NewsletterSettings.cshtml b/Ombi.UI/Views/Admin/NewsletterSettings.cshtml
index 3d02e89d4..2b9f52838 100644
--- a/Ombi.UI/Views/Admin/NewsletterSettings.cshtml
+++ b/Ombi.UI/Views/Admin/NewsletterSettings.cshtml
@@ -7,46 +7,48 @@