Skip to content

Commit

Permalink
add support for smtp clients that requires no authentication.
Browse files Browse the repository at this point in the history
  • Loading branch information
hargata committed May 31, 2024
1 parent dde9688 commit 7ab476a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Helper/MailHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,11 @@ private bool SendEmail(List<string> emailTo, string emailSubject, string emailBo
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);
Expand Down

0 comments on commit 7ab476a

Please sign in to comment.