Skip to content

Commit 64ea0e2

Browse files
authored
Merge pull request #533 from hargata/Hargata/532
add support for smtp clients that requires no authentication.
2 parents de41ca9 + 7ab476a commit 64ea0e2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Helper/MailHelper.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,11 @@ private bool SendEmail(List<string> emailTo, string emailSubject, string emailBo
146146
using (var client = new SmtpClient())
147147
{
148148
client.Connect(server, mailConfig.Port, MailKit.Security.SecureSocketOptions.Auto);
149-
client.Authenticate(mailConfig.Username, mailConfig.Password);
149+
//perform authentication if either username or password is provided.
150+
//do not perform authentication if neither are provided.
151+
if (!string.IsNullOrWhiteSpace(mailConfig.Username) || !string.IsNullOrWhiteSpace(mailConfig.Password)) {
152+
client.Authenticate(mailConfig.Username, mailConfig.Password);
153+
}
150154
try
151155
{
152156
client.Send(message);

0 commit comments

Comments
 (0)