Skip to content

Commit

Permalink
#4273 Fixed case when email account credentials aren't required for s…
Browse files Browse the repository at this point in the history
…ent with requests
  • Loading branch information
exileDev committed Apr 10, 2020
1 parent 76261af commit c00c50b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Libraries/Nop.Services/Messages/SmtpBuilder.cs
Expand Up @@ -57,9 +57,14 @@ public virtual SmtpClient Build(EmailAccount emailAccount = null)
emailAccount.Port,
emailAccount.EnableSsl ? SecureSocketOptions.SslOnConnect : SecureSocketOptions.StartTlsWhenAvailable);

client.Authenticate(emailAccount.UseDefaultCredentials ?
CredentialCache.DefaultNetworkCredentials :
new NetworkCredential(emailAccount.Username, emailAccount.Password));
if (emailAccount.UseDefaultCredentials)
{
client.Authenticate(CredentialCache.DefaultNetworkCredentials);
}
else if (!string.IsNullOrWhiteSpace(emailAccount.Username))
{
client.Authenticate(new NetworkCredential(emailAccount.Username, emailAccount.Password));
}

return client;
}
Expand Down

0 comments on commit c00c50b

Please sign in to comment.