Skip to content

Commit e65baae

Browse files
authored
Remove the need of Smtp.Host config when using PickupDirectoryLocation (#11548)
1 parent bc80892 commit e65baae

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/Umbraco.Core/Configuration/Models/GlobalSettings.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ public class GlobalSettings
159159
public bool IsSmtpServerConfigured => !string.IsNullOrWhiteSpace(Smtp?.Host);
160160

161161
/// <summary>
162+
/// Gets a value indicating whether there is a physical pickup directory configured.
163+
/// </summary>
164+
public bool IsPickupDirectoryLocationConfigured => !string.IsNullOrWhiteSpace(Smtp?.PickupDirectoryLocation);
165+
162166
/// Gets a value indicating whether TinyMCE scripting sanitization should be applied
163167
/// </summary>
164168
[DefaultValue(StaticSanitizeTinyMce)]
@@ -174,4 +178,4 @@ public class GlobalSettings
174178
[DefaultValue(StaticSqlWriteLockTimeOut)]
175179
public TimeSpan SqlWriteLockTimeOut { get; } = TimeSpan.Parse(StaticSqlWriteLockTimeOut);
176180
}
177-
}
181+
}

src/Umbraco.Infrastructure/Mail/EmailSender.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,13 @@ private async Task SendAsyncInternal(EmailMessage message, string emailType, boo
7575
}
7676
}
7777

78-
var isPickupDirectoryConfigured = !string.IsNullOrWhiteSpace(_globalSettings.Smtp?.PickupDirectoryLocation);
79-
80-
if (_globalSettings.IsSmtpServerConfigured == false && !isPickupDirectoryConfigured)
78+
if (!_globalSettings.IsSmtpServerConfigured && !_globalSettings.IsPickupDirectoryLocationConfigured)
8179
{
8280
_logger.LogDebug("Could not send email for {Subject}. It was not handled by a notification handler and there is no SMTP configured.", message.Subject);
8381
return;
8482
}
8583

86-
if (isPickupDirectoryConfigured && !string.IsNullOrWhiteSpace(_globalSettings.Smtp?.From))
84+
if (_globalSettings.IsPickupDirectoryLocationConfigured && !string.IsNullOrWhiteSpace(_globalSettings.Smtp?.From))
8785
{
8886
// The following code snippet is the recommended way to handle PickupDirectoryLocation.
8987
// 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,
154152
/// </summary>
155153
/// <remarks>
156154
/// We assume this is possible if either an event handler is registered or an smtp server is configured
155+
/// or a pickup directory location is configured
157156
/// </remarks>
158-
public bool CanSendRequiredEmail() => _globalSettings.IsSmtpServerConfigured || _notificationHandlerRegistered;
157+
public bool CanSendRequiredEmail() => _globalSettings.IsSmtpServerConfigured
158+
|| _globalSettings.IsPickupDirectoryLocationConfigured
159+
|| _notificationHandlerRegistered;
159160
}
160-
}
161+
}

0 commit comments

Comments
 (0)