In this article I will explain with an example, how to resolve the following error while sending email using MailKit in .Net.
MailKit.ServiceNotAuthenticatedException: 5.7.0 Authentication Required.
Note: For more details on how to send Email using MailKit, please refer my article Send Email using MailKit in ASP.Net WebForms.
 
 
Error
The following error occurs when you try to send email with MailKit using credentials in your .Net application.
5.7.0 Authentication Required. For more information, go to
5.7.0  https://support.google.com/mail/?p=WantAuthError v124-20020a626182000000b006d96d753ca0sm25381832pfb.38 - gsmtp
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: MailKit.ServiceNotAuthenticatedException: 5.7.0 Authentication Required. For more information, go to
5.7.0  https://support.google.com/mail/?p=WantAuthError v124-20020a626182000000b006d96d753ca0sm25381832pfb.38 - gsmtp
 
 
.Net MailKit Error: 5.7.0 Authentication Required
 
 
Solution
This error means that the SMTP Server requires Authentication and hence when using MailKit, the Authenticate method of SmtpClient class object must be called with valid UserName and Password of the SMTP Server.
.Net MailKit Error: 5.7.0 Authentication Required
 
Note: If you are using Gmail credentials then, refer this article GMAIL Error: The SMTP server requires a secure connection or the client was not authenticated.