"The IMAP server has unexpectedly disconnected" 关于 Mailkit GetMessage 方法
"The IMAP server has unexpectedly disconnected" on Mailkit GetMessage Method
我想使用 mailkit 接收电子邮件,但在 selectedFolder.GetMessage 方法上收到此错误:"The IMAP server has unexpectedly disconnected"。
此问题仅针对 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[]
问题是您与服务器的 TCP/IP 连接被切断了。
发生这种情况的原因有很多,包括:
- 服务器崩溃
- 服务器已重启
- 服务器失去网络连接
- 客户端失去网络连接
您只需要通过尝试重新连接并重新发出命令来处理这些意外断开连接。
我想使用 mailkit 接收电子邮件,但在 selectedFolder.GetMessage 方法上收到此错误:"The IMAP server has unexpectedly disconnected"。
此问题仅针对 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[]
问题是您与服务器的 TCP/IP 连接被切断了。
发生这种情况的原因有很多,包括:
- 服务器崩溃
- 服务器已重启
- 服务器失去网络连接
- 客户端失去网络连接
您只需要通过尝试重新连接并重新发出命令来处理这些意外断开连接。