From eb26b38f2c83b0553eb6013e2b68bfed4a7214f2 Mon Sep 17 00:00:00 2001
From: bakerboy448 <55419169+bakerboy448@users.noreply.github.com>
Date: Wed, 30 Jun 2021 23:16:29 -0500
Subject: [PATCH] New: Replace SmtpClient with Mailkit
Closes #723
---
src/Directory.Packages.props | 1 +
src/NzbDrone.Core/Notifications/Email/Email.cs | 13 +++++++++----
src/NzbDrone.Core/Readarr.Core.csproj | 1 +
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props
index baa1560b2..5b3aaae87 100644
--- a/src/Directory.Packages.props
+++ b/src/Directory.Packages.props
@@ -14,6 +14,7 @@
+
diff --git a/src/NzbDrone.Core/Notifications/Email/Email.cs b/src/NzbDrone.Core/Notifications/Email/Email.cs
index 1bd58b294..40ef6f7d8 100644
--- a/src/NzbDrone.Core/Notifications/Email/Email.cs
+++ b/src/NzbDrone.Core/Notifications/Email/Email.cs
@@ -36,7 +36,7 @@ public override void OnReleaseImport(BookDownloadMessage message)
var paths = Settings.AttachFiles ? message.BookFiles.SelectList(a => a.Path) : null;
- SendEmail(Settings, BOOK_DOWNLOADED_TITLE_BRANDED, body, paths);
+ SendEmail(Settings, BOOK_DOWNLOADED_TITLE_BRANDED, body, false, paths);
}
public override void OnHealthIssue(HealthCheck.HealthCheck message)
@@ -95,16 +95,21 @@ private void SendEmail(EmailSettings settings, string subject, string body, bool
Text = body
};
- _logger.Debug("Sending email Subject: {0}", subject);
-
if (attachmentUrls != null)
{
+ var builder = new BodyBuilder();
+ builder.HtmlBody = body;
foreach (var url in attachmentUrls)
{
- email.Attachments.Add(new Attachment(url));
+ byte[] bytes = System.IO.File.ReadAllBytes(url);
+ builder.Attachments.Add(url, bytes);
+ _logger.Trace("Attaching: {0}", url);
}
+
+ email.Body = builder.ToMessageBody();
}
+ _logger.Debug("Sending email Subject: {0}", subject);
try
{
Send(email, settings);
diff --git a/src/NzbDrone.Core/Readarr.Core.csproj b/src/NzbDrone.Core/Readarr.Core.csproj
index c2a0709ab..e9a2bb1c8 100644
--- a/src/NzbDrone.Core/Readarr.Core.csproj
+++ b/src/NzbDrone.Core/Readarr.Core.csproj
@@ -13,6 +13,7 @@
+