Skip to content

Commit

Permalink
Merge pull request #533 from hargata/Hargata/532
Browse files Browse the repository at this point in the history
add support for smtp clients that requires no authentication.
  • Loading branch information
hargata authored May 31, 2024
2 parents de41ca9 + 7ab476a commit 64ea0e2
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 64ea0e2

Please sign in to comment.