Mailkit在IMAP响应中提取“意外令牌:[qstring:"Multipart message"]] [英] Mailkit Fetch "Unexpected token in IMAP response: [qstring: "Multipart message"]"

查看:98
本文介绍了Mailkit在IMAP响应中提取“意外令牌:[qstring:"Multipart message"]]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到一条带有消息的 ImapProtocolException :

I'm getting an ImapProtocolException with a message:

"Unexpected token in IMAP response: [qstring: "Multipart message"]" when issuing  zInbox.Fetch(uids, MailKit.MessageSummaryItems.UniqueId Or MailKit.MessageSummaryItems.BodyStructure Or MailKit.MessageSummaryItems.Envelope)

但是另一方面,如果我使用 GetMessage(uids),一切正常,没有错误.

But on the other hand if I use GetMessage(uids) all goes fine, no error.

这里是提取中的 ProtocolLogger (您可能会注意到没有提取完成"消息):

Here is ProtocolLogger from Fetch (you can notice no Fetch Completed message):

C: A00000790 UID FETCH 97824 (UID ENVELOPE BODYSTRUCTURE)
S: * 24320 FETCH (UID 97824 ENVELOPE ("Mon, 26 Oct 2015 16:48:44    +0000" "NFe" ((NIL NIL "fatsc" "makrocentral.com.br")) NIL NIL ((NIL NIL "fiscal" "generale.ind.br")) NIL NIL NIL "<20151026164845.43268801F3AD@mail-smtp08-mia.tpn.terra.com>") BODYSTRUCTURE (("text" "plain" ("charset" "ISO-8859-1") NIL "Message text" "Quoted-printable" 227 8 NIL ("inline" NIL) NIL NIL)("application" "octet-stream" ("name" "42151000460986000506550040000387401000387404-nfe.xml") NIL "Attached file: 42151000460986000506550040000387401000387404-nfe.xml" "Base64" 11086 NIL ("attachment" ("filename" "42151000460986000506550040000387401000387404-nfe.xml")) NIL NIL)("application" "pdf" ("name" "42151000460986000506550040000387401000387404-nfe.pdf") NIL "Attached file: 42151000460986000506550040000387401000387404-nfe.pdf" "Base64" 50364 NIL ("attachment" ("filename" "42151000460986000506550040000387401000387404-nfe.pdf")) NIL NIL) "mixed" ("boundary" "017AC96C_005ED075_Synapse_boundary") "Multipart message" NIL))

使用 GetMessage(uids)时,Protocologger给了我一个有趣的信息:

When using GetMessage(uids), Protocologger give me an interesting info:

S: X-mailer: Synapse - Pascal TCP/IP library by Lukas Gebauer

在使用另一个库时,我已经对此邮件程序遇到了问题.

I already have problems with this mailer when using another library.

据我了解,获取" 属于 MailKit ,而"GetMessage" 属于 MimeKit .

As I understand "Fetch" belongs to MailKit and "GetMessage" belongs to MimeKit.

因此,有什么替代方法可以继续进行提取而不是使用 GetMessage ? 循环浏览约1500封邮件并下载每封邮件,只是为了获取附件名称需要很长时间?

So, is there any work-around to proceed with Fetch instead of use GetMessage? Loop through ~1500 mails and download each one just to get attachments names take a very long time?

这里的人是否对邮件发件人有类似的问题,例如"Synapse-Lukas Gebauer的Pascal TCP/IP库" ?

Does anybody here had a similar problems with mailer like this one "Synapse - Pascal TCP/IP library by Lukas Gebauer"?

所以我认为现在有更多信息和问题.自从启动此线程以来,我正在处理BODYSTRUCTURE,而对RFC 3501的了解(至少对我而言)不太清楚. 我再次回到谈论突触"的地方,这是Log中的字符串,它给了我意外的令牌.

So I think now have some more info and questions. Since started this thread I'm dealing with BODYSTRUCTURE and not so much clear (at least to me) RFC 3501. I have back to talk about "Synapse" again, here is string from Log, the that give me Unexpected Token.

S: * 22300 FETCH (UID 32388 ENVELOPE ("Thu, 6 Sep 2018 13:19:10 -0300" "Zebra - XML sent" (("Zebra" NIL "invoice" "zebra.com")) NIL NIL ((NIL NIL "payments" "cat.com")) ((NIL NIL "invoice" "zebra.com") (NIL NIL "mary" "zebra.com")(NIL NIL "igor" "zebra.com")) NIL NIL "<20180906161753.3F4A774030A@proxy.tiger.com>") BODYSTRUCTURE (("text" "plain" ("charset" "UTF-8") NIL "Message text" "Quoted-printable" 209 6 NIL ("inline" NIL) NIL NIL)("text" "xml" ("name" "4441004299066.xml") NIL "4441004299066.xml" "Base64" 10642 137 NIL ("inline" ("filename" "4441004299066.xml")) NIL NIL)("application" "pdf" ("name" "4441004299066.pdf") NIL "4441004299066.pdf" "Base64" 48448 NIL ("inline" ("filename" "4441004299066.pdf")) NIL NIL) "mixed" ("boundary" "6624CFB2_17170C36_Synapse_boundary") "Multipart message" NIL))

正如评论中指出的那样,问题出在多部分消息" NIL 的末尾,另一方面,运行良好的BodyStructure可以以"NIL NIL"或**"NIL pt结尾" -br.

As pointed in comments, the problem is at the end part "Multipart message" NIL, on the other hand a BodyStructure that works fine can end with "NIL NIL" or **"NIL pt-br".

好吧,现在的问题是. BodyStructure字符串的最后2个字段应该是什么? 同时,我发现了这一点: 1)多部分消息"来自消息头的内容描述" 2)"pt-br"来自邮件标题的"Content-Language"

So, ok, now the question is. What should be the last 2 fields in BodyStructure string? In mean time I found this: 1) "Multipart message" is coming from "Content-Description" of message header 2) "pt-br" is coming from "Content-Language" of message header

我完全同意遵循RFC,但是看起来最后两个值不清楚应从何处来. 我是说内容语言还是语言标签?内容配置还是内容描述?

I totally agree to follow RFC, but looks like the last 2 values are not clear from where they should came from. I mean Content-Language or Language-Tag? Content-Disposition or Content-Description?

由于Exchange Server和Outlook,office365.com的广泛使用,对我来说,我不得不继续使用GetMessage并忘记获取.

Since Exchanges Server and outlook,office365.com become widely used, to me sounds I have to stay using GetMessage and forget about Fetch.

推荐答案

问题是IMAP服务器以完全中断的响应进行了响应.

The problem is that the IMAP server responded with a completely broken response.

根据IMAP规范,"mixed"令牌后面的多部分语法应为:

According to the IMAP specification, the multipart syntax following the "mixed" token should be:

body-ext-mpart  = body-fld-param [SP body-fld-dsp [SP body-fld-lang
              [SP body-fld-loc *(SP body-extension)]]]
                ; MUST NOT be returned on non-extensible
                ; "BODY" fetch
body-fld-param  = "(" string SP string *(SP string SP string) ")" / nil
body-fld-dsp    = "(" string SP body-fld-param ")" / nil
body-fld-lang   = nstring / "(" string *(SP string) ")"
body-fld-loc    = nstring

但是我们得到的是:("boundary" "017AC96C_005ED075_Synapse_boundary") "Multipart message" NIL)

这实际上分为以下几种类型的令牌:

This essentially breaks down into the following types of tokens:

body-fld-param [SP] string [SP] nil

注意不允许使用"Multipart message". 应该应该是一个NIL或类似以下内容的内容:("inline" ("name" "value"))

Notice how "Multipart message" is not allowed. What should be there is either a NIL or something like: ("inline" ("name" "value"))

换句话说,您的IMAP服务器未在语法上说出正确的IMAP. MailKit无法理解您的IMAP服务器试图说的话.

In other words, your IMAP server is not speaking grammatically correct IMAP. There's no way that MailKit can understand what your IMAP server is trying to say.

注意:问题是IMAP服务器,而不是这种情况下的Synapse Mailer.

Note: the problem is the IMAP server, not the Synapse Mailer in this case.

这篇关于Mailkit在IMAP响应中提取“意外令牌:[qstring:"Multipart message"]]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆