IMAP 搜索命令的替代方法

发布于 2024-10-26 03:58:24 字数 138 浏览 1 评论 0原文

我需要 IMAP 搜索命令的替代方案“搜索 1:* 未见未删除”,因为电子邮件服务器禁止该搜索命令。我尝试使用“状态(未见)”,但尽管有未读消息,但它始终返回零。该命令还有其他选择吗?提前致谢。

I need an alternative for IMAP search command "A search 1:* unseen not deleted" since the email server is forbidding the search command. I tried using "A status (unseen)" but it always returns zero though there's an unread message. Is there any alternative for the command? Thanks in advance.

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

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

发布评论

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

评论(1

一页 2024-11-02 03:58:24

您的问题是 IMAP 服务器根本不支持 SEARCH,还是它不喜欢您的特定 SEARCH 命令?如果是后者,我们可以简化:(

A SEARCH UNSEEN UNDELETED

因为 1:* 是隐式的)。甚至更简单——以防万一服务器根本不喜欢将 SEARCH 术语放在一起——可以是:

A SEARCH UNSEEN
B SEARCH DELETED

并在代码中逻辑地执行 AND 操作。

暴力的方法是:

C UID FETCH 1:* FLAGS

然后挑选出所有既没有 \Seen 也没有 \Deleted 的。 (我建议使用UID FETCH,因为类似的FETCH命令将在空文件夹上返回BAD。)

此外,您不应该对当前选定的对象调用 STATUS 命令文件夹

注意:STATUS 命令旨在访问
当前所选邮箱以外的邮箱状态
邮箱。因为 STATUS 命令可能会导致
邮箱要在内部打开,并且因为这个
可以通过其他方式获取有关所选内容的信息
邮箱,STATUS 命令不应该用在
当前选择的邮箱。

Is your problem that the IMAP server doesn't support SEARCH at all, or that it doesn't like your particular SEARCH command? If it's the latter, we can simplify:

A SEARCH UNSEEN UNDELETED

(as 1:* is implicit). Even simpler -- just in case the server doesn't like and-ing SEARCH terms together at all -- would be:

A SEARCH UNSEEN
B SEARCH DELETED

and logically doing the AND in your code.

The brute-force way of doing it is:

C UID FETCH 1:* FLAGS

and then picking out all the ones with neither \Seen nor \Deleted. (I'm suggesting UID FETCH because a similar FETCH command will return BAD on an empty folder.)

Also, you're not supposed to call the STATUS command on the currently-selected folder:

Note: The STATUS command is intended to access the
status of mailboxes other than the currently selected
mailbox. Because the STATUS command can cause the
mailbox to be opened internally, and because this
information is available by other means on the selected
mailbox, the STATUS command SHOULD NOT be used on the
currently selected mailbox.

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