Skip to content

Commit cb06170

Browse files
committed
Remove need of SMTP.Host config when defining pickupdirectorylocation
1 parent acaece6 commit cb06170

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ public class GlobalSettings
157157
/// </summary>
158158
public bool IsSmtpServerConfigured => !string.IsNullOrWhiteSpace(Smtp?.Host);
159159

160+
/// <summary>
161+
/// Gets a value indicating whether there is a physical pickup directory configured.
162+
/// </summary>
163+
public bool IsPickupDirectoryLocationConfigured => !string.IsNullOrWhiteSpace(Smtp?.PickupDirectoryLocation);
164+
160165
/// <summary>
161166
/// An int value representing the time in milliseconds to lock the database for a write operation
162167
/// </summary>

src/Umbraco.Infrastructure/Mail/EmailSender.cs

Lines changed: 6 additions & 5 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
}
160161
}

0 commit comments

Comments
 (0)