In this article I will explain with an example, how to resolve the following error while sending email using MailKit in .Net.
System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 00.000.000.000:25
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 email credentials in your .Net application.
An attempt was made to access a socket in a way forbidden by its access permissions 00.000.000.000:25
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: System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 00.000.000.000:25
 
.Net MailKit Error: An attempt was made to access a socket in a way forbidden
 
 
Solution
This error happens when the SMTP Mail Server is not reachable, thus you need to make sure the SMTP Mail Server name is correct and you are connected to the internet.