From 7ab476a88f9d3f5e805007ee6c87cb21aeef9594 Mon Sep 17 00:00:00 2001 From: "DESKTOP-T0O5CDB\\DESK-555BD" Date: Fri, 31 May 2024 09:11:09 -0600 Subject: [PATCH] add support for smtp clients that requires no authentication. --- Helper/MailHelper.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Helper/MailHelper.cs b/Helper/MailHelper.cs index da82317..f1dc6fe 100644 --- a/Helper/MailHelper.cs +++ b/Helper/MailHelper.cs @@ -146,7 +146,11 @@ namespace CarCareTracker.Helper using (var client = new SmtpClient()) { client.Connect(server, mailConfig.Port, MailKit.Security.SecureSocketOptions.Auto); - client.Authenticate(mailConfig.Username, mailConfig.Password); + //perform authentication if either username or password is provided. + //do not perform authentication if neither are provided. + if (!string.IsNullOrWhiteSpace(mailConfig.Username) || !string.IsNullOrWhiteSpace(mailConfig.Password)) { + client.Authenticate(mailConfig.Username, mailConfig.Password); + } try { client.Send(message);