When you use the Pop3Client to connect to a server using SSL, the certificate of the server is validated.
Sometimes you want to do the validation yourself, since you might be using a self-signed certificate or the like.
Here is how you do that:
/// Example showing:
/// - how to set timeouts
/// - how to override the SSL certificate checks with your own implementation
/// <param name="hostname">Hostname of the server. For example: pop3.live.com</param>
/// <param name="port">Host port to connect to. Normally: 110 for plain POP3, 995 for SSL POP3</param>
/// <param name="timeouts">Read and write timeouts used by the Pop3Client</param>
public static void BypassSslCertificateCheck(string hostname, int port, int timeouts)
// The client disconnects from the server when being disposed
using (Pop3Client client = new Pop3Client())
// Connect to the server using SSL with specified settings
// true here denotes that we connect using SSL
// The certificateValidator can validate the SSL certificate of the server.
// This might be needed if the server is using a custom normally untrusted certificate
client.Connect(hostname, port, true, timeouts, timeouts, certificateValidator);
// Do something extra now that we are connected to the server
private static bool certificateValidator(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslpolicyerrors)
// We should check if there are some SSLPolicyErrors, but here we simply say that
// the certificate is okay - we trust it.
As you can see, you pass a validation method to the Connect method of the Pop3Client.
When the certificate needs to be validated, your supplied method will be called.