When I tried to send automated emails using C#, I got the following error:
“The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated“
- The account used to sent email is not authenticated on the Exchange.
- Send – Receive connectors are not configured properly.
- Check with your Exchange administrator to permit the e-mail account to send e-mail.
- Review the default receive connector and select anonymous users on the permissions groups tab.
If the previous points have been checked and still the issue exists so you should check your code by doing the following :
smtpClient.UseDefaultCredentials =false; smtpClient.Credentials = new System.Net.NetworkCredential(From, Password);
Also, try to enable SSL before smtpClient.Send()
smtpClient.EnableSsl = true;
If you didn’t specify the user/pwd of the SmtpClient, use
smtpClient.UseDefaultCredentials = true;
Note: SmtpClient is using the app pool identity account to connect to SMTP host.
- If the app pool identity is a domain account
- You should give it the appropriate permission right to send E-mail.
- If the app pool identity is not a domain account,
- Try to change the app pool identity to a domain account which has right to send E-Mail.
- C# Development.