通过IMAP读取字符串问题

发布于 2024-10-16 20:04:13 字数 356 浏览 4 评论 0原文

我正在处理 IMAP,因此只需读取正文 (body[header.fields (DATE FROM SUBJECT)]) 我就传递此命令。

但问题是,有时我的字符串会返回除原始字符串之外的额外内容。 有时我得到的绳子的有限部分意味着身体的一半。 因此,每当我传递第二个命令时,它都会接受第一个命令并返回结果 第一个命令待定结果;

所以我担心的是我无法检索身体部位的正确数据。

根据我的知识,我认为这是由于互联网数据包 tresfersize 造成的,但除此之外,看看 Outlook 或任何其他邮件管理器都可以正常工作,所以这是什么机制 该数据正在检索。

或者我的编码要做的任何其他事情......

谢谢......

I am working on a IMAP, so just reading the body (body[header.fields (DATE FROM SUBJECT)]) I am passing this command.

But problem is like there some time my string return extra stuff excetp from my original string.
and some times I had getting limited part of the string means half part of the body.
so whenever I am passing second command it will accept as a first command and return result as the
first command pending resul.;

so the my concern is that I am not able to retrive proper data as of the part of the body.

as per my knowladge I think it's happen due to the internet datapacket tresfersize, but apart from this look at outlook or any other mail manager will work properly so what this is the mechanisam for
this data retriving.

or anything else to do fo my coding.....

Thanks..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心头的小情儿 2024-10-23 20:04:14

从 IMAP 服务器发布包含“额外内容”的示例响应会有所帮助。

您最有可能面临的问题是未标记的服务器响应。

RFC3501 的内容如下:

状态响应可以标记或取消标记。带标记的状态响应指示客户端命令的完成结果(OK、NO 或 BAD 状态),并具有与命令匹配的标记:

C: a002 NOOP
S: a002 OK NOOP completed

某些状态响应和所有服务器数据均未标记。一个
未标记的响应由标记“*”而不是标记来指示。

C: a047 NOOP
S: * 22 EXPUNGE
S: * 23 EXISTS
S: * 3 RECENT
S: * 14 FETCH (FLAGS (\Seen \Deleted))
S: a047 OK NOOP completed

因此,您需要区分这两种响应类型。

请记住,检查每个收到的行是否都以“*”字符开头是不够的,因为您的电子邮件也可能包含以星号字符开头的行:

C:    a004 fetch 12 body[header]
S:    * 12 FETCH (RFC822 {342}
S:    Date: Wed, 17 Jul 1996 02:23:25 -0700 (PDT)
S:    From: Terry Gray <[email protected]>
S:    Subject: IMAP4rev1 WG mtg summary and minutes
S:    MIME-Version: 1.0
S:    
S:    * This is email body containing start char
S:    )
S:    a004 OK FETCH completed

{342} 是您应该读取的确切字节数。

最重要的是不要使用现有的库重新发明轮子。

您可以查看我的 IMAP 组件(不是免费的)。

Posting a sample response from the IMAP server that contains the "extra stuff" would help.

The problem you are most likely facing is with untagged server responses.

Heres what RFC3501 says:

Status responses can be tagged or untagged. Tagged status responses indicate the completion result (OK, NO, or BAD status) of a client command, and have a tag matching the command:

C: a002 NOOP
S: a002 OK NOOP completed

Some status responses, and all server data, are untagged. An
untagged response is indicated by the token "*" instead of a tag.

C: a047 NOOP
S: * 22 EXPUNGE
S: * 23 EXISTS
S: * 3 RECENT
S: * 14 FETCH (FLAGS (\Seen \Deleted))
S: a047 OK NOOP completed

So you need to distinguish between those 2 response types.

Please remember that checking if every received line starts from '*' character is not enough, as your email message may also have lines starting from star character:

C:    a004 fetch 12 body[header]
S:    * 12 FETCH (RFC822 {342}
S:    Date: Wed, 17 Jul 1996 02:23:25 -0700 (PDT)
S:    From: Terry Gray <[email protected]>
S:    Subject: IMAP4rev1 WG mtg summary and minutes
S:    MIME-Version: 1.0
S:    
S:    * This is email body containing start char
S:    )
S:    a004 OK FETCH completed

{342} is the exact number of bytes you are supposed to read.

The bottom line is don't reinvent the wheel use existing library.

You can check out mine IMAP component (not free).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文