From ef20d870ee7bf49d921eb193a9cfb74b4c5ba1cc Mon Sep 17 00:00:00 2001 From: sbwalker Date: Tue, 30 Dec 2025 08:33:28 -0500 Subject: [PATCH] fix #5930 - NotificationJob not sending emails (reverting #5848) --- Oqtane.Server/Infrastructure/Jobs/NotificationJob.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Oqtane.Server/Infrastructure/Jobs/NotificationJob.cs b/Oqtane.Server/Infrastructure/Jobs/NotificationJob.cs index a280c71f..6435c45b 100644 --- a/Oqtane.Server/Infrastructure/Jobs/NotificationJob.cs +++ b/Oqtane.Server/Infrastructure/Jobs/NotificationJob.cs @@ -160,7 +160,7 @@ namespace Oqtane.Infrastructure var toEmail = notification.ToEmail ?? ""; var toName = notification.ToDisplayName ?? ""; - // get sender and receiver information from user information if available + // get sender from user information if "from" email or name not specified and user id is available if ((string.IsNullOrEmpty(fromEmail) || string.IsNullOrEmpty(fromName)) && notification.FromUserId != null) { var user = userRepository.GetUser(notification.FromUserId.Value); @@ -170,6 +170,7 @@ namespace Oqtane.Infrastructure fromName = string.IsNullOrEmpty(fromName) ? user.DisplayName ?? "" : fromName; } } + // get recipient from user information if "to" email or name not specified and user id is available if ((string.IsNullOrEmpty(toEmail) || string.IsNullOrEmpty(toName)) && notification.ToUserId != null) { var user = userRepository.GetUser(notification.ToUserId.Value); @@ -185,26 +186,25 @@ namespace Oqtane.Infrastructure MailboxAddress from = null; var mailboxAddressValidationError = ""; - // sender - if ((settingRepository.GetSettingValue(settings, "SMTPRelay", "False") == "True") && string.IsNullOrEmpty(fromEmail)) + // SMTP Sender should always be used if site is not using an Open Relay or if the "from" email address is not specified (ie. system messages) + if (settingRepository.GetSettingValue(settings, "SMTPRelay", "False") != "True" || string.IsNullOrEmpty(fromEmail)) { fromEmail = settingRepository.GetSettingValue(settings, "SMTPSender", ""); fromName = string.IsNullOrEmpty(fromName) ? site.Name : fromName; } if (MailboxAddress.TryParse(fromEmail, out from)) { - from.Name = fromName; + from.Name = fromName; //override with "from" name set previously } else { - mailboxAddressValidationError += $" Invalid Sender: {fromName} <{fromEmail}>"; } // recipient if (MailboxAddress.TryParse(toEmail, out to)) { - to.Name = toName; + to.Name = toName; //override with "to" name set previously } else {