From cb06170818b5a15b6d73badba84e0c18e24b360d Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 29 Oct 2021 23:26:22 +0200 Subject: [PATCH] Remove need of SMTP.Host config when defining pickupdirectorylocation --- .../Configuration/Models/GlobalSettings.cs | 5 +++++ src/Umbraco.Infrastructure/Mail/EmailSender.cs | 11 ++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Core/Configuration/Models/GlobalSettings.cs b/src/Umbraco.Core/Configuration/Models/GlobalSettings.cs index 7799fec5eacd..71ea84f1adad 100644 --- a/src/Umbraco.Core/Configuration/Models/GlobalSettings.cs +++ b/src/Umbraco.Core/Configuration/Models/GlobalSettings.cs @@ -157,6 +157,11 @@ public class GlobalSettings /// public bool IsSmtpServerConfigured => !string.IsNullOrWhiteSpace(Smtp?.Host); + /// + /// Gets a value indicating whether there is a physical pickup directory configured. + /// + public bool IsPickupDirectoryLocationConfigured => !string.IsNullOrWhiteSpace(Smtp?.PickupDirectoryLocation); + /// /// An int value representing the time in milliseconds to lock the database for a write operation /// diff --git a/src/Umbraco.Infrastructure/Mail/EmailSender.cs b/src/Umbraco.Infrastructure/Mail/EmailSender.cs index 4ca3506fa97c..49dc669bb680 100644 --- a/src/Umbraco.Infrastructure/Mail/EmailSender.cs +++ b/src/Umbraco.Infrastructure/Mail/EmailSender.cs @@ -75,15 +75,13 @@ private async Task SendAsyncInternal(EmailMessage message, string emailType, boo } } - var isPickupDirectoryConfigured = !string.IsNullOrWhiteSpace(_globalSettings.Smtp?.PickupDirectoryLocation); - - if (_globalSettings.IsSmtpServerConfigured == false && !isPickupDirectoryConfigured) + if (!_globalSettings.IsSmtpServerConfigured && !_globalSettings.IsPickupDirectoryLocationConfigured) { _logger.LogDebug("Could not send email for {Subject}. It was not handled by a notification handler and there is no SMTP configured.", message.Subject); return; } - if (isPickupDirectoryConfigured && !string.IsNullOrWhiteSpace(_globalSettings.Smtp?.From)) + if (_globalSettings.IsPickupDirectoryLocationConfigured && !string.IsNullOrWhiteSpace(_globalSettings.Smtp?.From)) { // The following code snippet is the recommended way to handle PickupDirectoryLocation. // See more https://github.com/jstedfast/MailKit/blob/master/FAQ.md#q-how-can-i-send-email-to-a-specifiedpickupdirectory @@ -154,7 +152,10 @@ await client.ConnectAsync(_globalSettings.Smtp.Host, /// /// /// We assume this is possible if either an event handler is registered or an smtp server is configured + /// or a pickup directory location is configured /// - public bool CanSendRequiredEmail() => _globalSettings.IsSmtpServerConfigured || _notificationHandlerRegistered; + public bool CanSendRequiredEmail() => _globalSettings.IsSmtpServerConfigured + || _globalSettings.IsPickupDirectoryLocationConfigured + || _notificationHandlerRegistered; } }