From f7c35671b73a640c30a0dfe7d45040025ceedd32 Mon Sep 17 00:00:00 2001 From: Anatolii Grynchuk Date: Sat, 2 May 2026 03:45:59 +0300 Subject: [PATCH] fix: correct smtp ssl negotiation mode per port - Port 465: SslOnConnect (implicit SSL) - Port 587 + UseSsl: StartTls (STARTTLS upgrade) - UseSsl=false: None Ref: IT-628 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Controllers/Admin/AdminChannelsController.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/HrynCo.NotificationService.Web/Controllers/Admin/AdminChannelsController.cs b/HrynCo.NotificationService.Web/Controllers/Admin/AdminChannelsController.cs index 4aa3718..d05585d 100644 --- a/HrynCo.NotificationService.Web/Controllers/Admin/AdminChannelsController.cs +++ b/HrynCo.NotificationService.Web/Controllers/Admin/AdminChannelsController.cs @@ -163,7 +163,11 @@ public class AdminChannelsController : Controller }; using var client = new SmtpClient(); - var secureSocket = smtp.UseSsl ? SecureSocketOptions.SslOnConnect : SecureSocketOptions.StartTlsWhenAvailable; + var secureSocket = smtp.Port == 465 + ? SecureSocketOptions.SslOnConnect + : smtp.UseSsl + ? SecureSocketOptions.StartTls + : SecureSocketOptions.None; await client.ConnectAsync(smtp.Host, smtp.Port, secureSocket, ct); if (!string.IsNullOrWhiteSpace(smtp.Username))