Skip to content

Commit

Permalink
Revert accidental commit of "Remove need of SMTP.Host config when def…
Browse files Browse the repository at this point in the history
…ining pickupdirectorylocation"

This reverts commit cb06170.
  • Loading branch information
mikecp committed Oct 29, 2021
1 parent cb06170 commit bd63974
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
5 changes: 0 additions & 5 deletions src/Umbraco.Core/Configuration/Models/GlobalSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,6 @@ public class GlobalSettings
/// </summary>
public bool IsSmtpServerConfigured => !string.IsNullOrWhiteSpace(Smtp?.Host);

/// <summary>
/// Gets a value indicating whether there is a physical pickup directory configured.
/// </summary>
public bool IsPickupDirectoryLocationConfigured => !string.IsNullOrWhiteSpace(Smtp?.PickupDirectoryLocation);

/// <summary>
/// An int value representing the time in milliseconds to lock the database for a write operation
/// </summary>
Expand Down
11 changes: 5 additions & 6 deletions src/Umbraco.Infrastructure/Mail/EmailSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,15 @@ private async Task SendAsyncInternal(EmailMessage message, string emailType, boo
}
}

if (!_globalSettings.IsSmtpServerConfigured && !_globalSettings.IsPickupDirectoryLocationConfigured)
var isPickupDirectoryConfigured = !string.IsNullOrWhiteSpace(_globalSettings.Smtp?.PickupDirectoryLocation);

if (_globalSettings.IsSmtpServerConfigured == false && !isPickupDirectoryConfigured)
{
_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 (_globalSettings.IsPickupDirectoryLocationConfigured && !string.IsNullOrWhiteSpace(_globalSettings.Smtp?.From))
if (isPickupDirectoryConfigured && !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
Expand Down Expand Up @@ -152,10 +154,7 @@ await client.ConnectAsync(_globalSettings.Smtp.Host,
/// </summary>
/// <remarks>
/// 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
/// </remarks>
public bool CanSendRequiredEmail() => _globalSettings.IsSmtpServerConfigured
|| _globalSettings.IsPickupDirectoryLocationConfigured
|| _notificationHandlerRegistered;
public bool CanSendRequiredEmail() => _globalSettings.IsSmtpServerConfigured || _notificationHandlerRegistered;
}
}

0 comments on commit bd63974

Please sign in to comment.