MailKit: The IMAP server has unexpectedly disconnected. Microsoft Exchange Server 2003
Describe the bug Authenticate Exception
Platform (please complete the following information):
- OS: Windows
- .NET Framework: .Net Core 6
- MailKit Version: 3.5.0
Exception Connected to imap://...:143/?starttls=when-available S: * OK Microsoft Exchange Server 2003 IMAP4rev1 服务器版本 6.5.7638.1 (..com) 已就绪。 C: A00000000 CAPABILITY S: * CAPABILITY IMAP4 IMAP4rev1 IDLE LOGIN-REFERRALS MAILBOX-REFERRALS NAMESPACE LITERAL+ UIDPLUS CHILDREN S: A00000000 OK CAPABILITY completed. IMAP Connected C: A00000001 LOGIN ******** ******** S: A00000001 OK LOGIN completed. C: A00000002 CAPABILITY S: * CAPABILITY IMAP4 IMAP4rev1 IDLE LOGIN-REFERRALS MAILBOX-REFERRALS NAMESPACE LITERAL+ UIDPLUS CHILDREN S: A00000002 OK CAPABILITY completed. C: A00000003 NAMESPACE IMAPMailKit.Net.Imap.ImapProtocolException: The IMAP server has unexpectedly disconnected. at MailKit.Net.Imap.ImapStream.ReadAhead(Int32 atleast, CancellationToken cancellationToken) at MailKit.Net.Imap.ImapStream.ReadToken(String specials, CancellationToken cancellationToken) at MailKit.Net.Imap.ImapEngine.ReadTokenAsync(Boolean doAsync, CancellationToken cancellationToken) at MailKit.Net.Imap.ImapCommand.StepAsync(Boolean doAsync) at MailKit.Net.Imap.ImapEngine.IterateAsync(Boolean doAsync) at MailKit.Net.Imap.ImapEngine.RunAsync(ImapCommand ic, Boolean doAsync) at MailKit.Net.Imap.ImapEngine.QueryNamespacesAsync(Boolean doAsync, CancellationToken cancellationToken) at MailKit.Net.Imap.ImapClient.OnAuthenticatedAsync(String message, Boolean doAsync, CancellationToken cancellationToken) at MailKit.Net.Imap.ImapClient.AuthenticateAsync(Encoding encoding, ICredentials credentials, Boolean doAsync, CancellationToken cancellationToken) at MailKit.Net.Imap.ImapClient.Authenticate(Encoding encoding, ICredentials credentials, CancellationToken cancellationToken) at MailKit.MailService.Authenticate(Encoding encoding, String userName, String password, CancellationToken cancellationToken) at MailKit.MailService.Authenticate(String userName, String password, CancellationToken cancellationToken) at ConsoleApp1.Program.Main(String[] args) in D:\ConsoleApp1\ConsoleApp1\Program.cs:line 77
Code Snippets
using(var client=new ImapClient(new ProtocolLogger(Console.OpenStandardOutput())))
{
try
{
client.Connect("*.*.*.*", 143);
Console.WriteLine("IMAP Connected");
// client.ServerCertificateValidationCallback += (s, c, ch, e) => { return true; };
// client.AuthenticationMechanisms.Clear();
client.Authenticate(userName, password);
Console.WriteLine("IMAP Authenticate Success");
}
catch(Exception e)
{
}
}
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 24 (12 by maintainers)
Commits related to this issue
- Avoid using the NAMESPACE command for Exchange 2003 Fixes issue #1512 — committed to jstedfast/MailKit by jstedfast a year ago
@TechGuyAlabama
Port 995 is POP3, not SMTP.
The SMTP ports are: 25, 465 (SslOnConnect), or 587.
@xiongjx
There’s nothing MailKit can do in your situation. Your network connection was lost, either because the server disconnected your or because your router went down or something.
Just to throw it out there, my issue ended up being that the user setup extra security on the account which required an App password on Yahoo.
For reference: https://help.yahoo.com/kb/SLN15241.html
Thanks for the help!