Skip to content

Commit

Permalink
Skip SMTP authentication if both username and password are empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed May 12, 2021
1 parent e6e2463 commit 07f912c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Server/Services/EmailSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ public async Task<bool> SendEmailAsync(string toEmail, string replyTo, string su

await client.ConnectAsync(AppConfig.SmtpHost, AppConfig.SmtpPort);

await client.AuthenticateAsync(AppConfig.SmtpUserName, AppConfig.SmtpPassword);
if (!string.IsNullOrWhiteSpace(AppConfig.SmtpUserName) &&
!string.IsNullOrWhiteSpace(AppConfig.SmtpPassword))
{
await client.AuthenticateAsync(AppConfig.SmtpUserName, AppConfig.SmtpPassword);
}

await client.SendAsync(message);
await client.DisconnectAsync(true);
Expand Down

0 comments on commit 07f912c

Please sign in to comment.