I recently moved my code to MailKit library because I was using S22.Imap but I saw the maintenance wasn't that great.
I previously connected with my own mailserver through 143 and 993, but there is no way to do it through 993 and MailKit.
It just says "The IMAP server has unexpectedly disconnected". It doesn't even reach the Authenticate method, and the log uniquely says "Connected to imap://mail.xxx.com:993/".
I'm currently using the
imap.Connect(hostname, 993, SecureSocketOptions.None);
I've even tried with different SecureSocketOptions it has with no luck. Any idea what could be wrong? With works fine if I'm connecting through 143 and it worked through 993 when I used S22.Imap.
P.S: The Exception it throws is a MailKit.Net.Imap.ImapProtocolException
.
Thanks.
Port 993 is an SSL-wrapped port, so you need to use:
imap.Connect(hostname, 993, SecureSocketOptions.SslOnConnect);
For port 143, you probably want to use:
imap.Connect(hostname, 143, SecureSocketOptions.StartTlsWhenAvailable);