We are glad that you like our components! Thank you for your feedback.
We thought about your question and came up with this simple algorithm to decide which SslMode to use. It always uses explicit mode on port 110 and on other ports it tries first implicit and in need also explicit mode. This should cover most of POP3 servers. If a server runs implicitly secured TLS/SSL on port 110, it is practically a suicide, because no one will ever get there from normal pop3 clients, so we ignore this possibility (You could still detect it by detecting timeout which is rather time-costly.)
public void AutoDetectSslMode(Pop3 pop3, bool ssl, string server, int port, string expected)
{
if(ssl)
{
if (port == Pop3.DefaultPort)
{
pop3.Connect(server, port, SslMode.Explicit);
}
else // for ports other than 110 try implicit mode
{
try
{
pop3.Connect(server, port, SslMode.Implicit);
}
catch (TlsException ex)
{
if (ex.Message != "Fatal error 'ProtocolVersion' has been encountered on the local connection end.")
throw ex;
// if not implicit, try explicit mode
pop3.Connect(server, port, SslMode.Explicit);
}
}
}
else
{
pop3.Connect(server, port, SslMode.None);
}
}