Mailkit GetMessage方法上的“ IMAP服务器已意外断开连接”

时间:2019-02-03 13:43:59

标签: c# asp.net email imap mailkit

我想使用mailkit获取电子邮件,但收到以下错误:selectedFolder.GetMessage方法上出现“ IMAP服务器意外断开连接”的消息。

此问题仅适用于2或3条消息,而并非全部。

这是Mailkit日志

Connected to imap://*****:143/?starttls=when-available
S: * OK IMAP4rev1 SmarterMail
C: B00000000 CAPABILITY
S: * CAPABILITY IMAP4rev1 AUTH=CRAM-MD5 UIDPLUS QUOTA XLIST CHILDREN
S: B00000000 OK CAPABILITY completed
C: B00000001 AUTHENTICATE CRAM-MD5
S: + PDE4MDMxODE3NDkuNjMhdGEuY29tPg==
C: bW9zbGVtaUBwaWRtY28uaXIgZjUwZxYjhlNDQ=
S: B00000001 OK CRAM authentication successful
C: B00000002 CAPABILITY
S: * CAPABILITY IMAP4rev1 AUTH=CRAM-MD5 UIDPLUS QUOTA XLIST CHILDREN
S: B00000002 OK CAPABILITY completed
C: B00000003 LIST "" ""
S: * LIST (\Noselect) "/" ""
S: B00000003 OK LIST completed
C: B00000004 LIST "" "INBOX"
S: * LIST (\HasNoChildren) "/" "Inbox"
S: B00000004 OK LIST completed
C: B00000005 XLIST "" "*"
S: * XLIST (\HasNoChildren \Trash) "/" "Deleted Items"
S: * XLIST (\HasNoChildren) "/" "ESET Antispam"
S: * XLIST (\HasNoChildren \Inbox) "/" "Inbox"
S: * XLIST (\HasNoChildren) "/" "Infected Items"
S: * XLIST (\HasNoChildren \Spam) "/" "Junk E-Mail"
S: * XLIST (\HasNoChildren \Sent) "/" "Sent Items"
S: * XLIST (\HasNoChildren) "/" "Drafts"
S: B00000005 OK XLIST completed
C: B00000006 EXAMINE Inbox
S: * 44 EXISTS
S: * 0 RECENT
S: * OK [UNSEEN 24] Message 24 is first unseen
S: * OK [UIDVALIDITY 0] UIDs valid
S: * OK [UIDNEXT 1869] Predicted next UID
S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
S: * OK [PERMANENTFLAGS ()]
S: B00000006 OK [READ-ONLY] EXAMINE completed
C: B00000007 UID FETCH 1826 (BODY.PEEK[])
S: * 4 FETCH (BODY[] 

1 个答案:

答案 0 :(得分:1)

问题是您与服务器的TCP / IP连接正在断开。

这可能有多种原因,包括:

  1. 服务器崩溃
  2. 服务器已重新启动
  3. 服务器失去了网络连接
  4. 客户端失去了网络连接

您只需尝试重新连接并重新发出命令来处理这些意外断开连接。