April 30, 2012
Posted by on
When I tried to send an email from .Net code, I got the following exception.
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated
This was because the mail was sent from the office network. By default the credentials in the SmtpClient object is null. The issue was resolved by setting SmtpClient.UseDefaultCredentials to true.
mailClient.UseDefaultCredentials = true;