IMAP 搜索命令的替代方法
我需要 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的问题是 IMAP 服务器根本不支持
SEARCH
,还是它不喜欢您的特定SEARCH
命令?如果是后者,我们可以简化:(因为
1:*
是隐式的)。甚至更简单——以防万一服务器根本不喜欢将SEARCH
术语放在一起——可以是:并在代码中逻辑地执行 AND 操作。
暴力的方法是:
然后挑选出所有既没有
\Seen
也没有\Deleted
的。 (我建议使用UID FETCH
,因为类似的FETCH
命令将在空文件夹上返回BAD
。)此外,您不应该对当前选定的对象调用
STATUS
命令文件夹:Is your problem that the IMAP server doesn't support
SEARCH
at all, or that it doesn't like your particularSEARCH
command? If it's the latter, we can simplify:(as
1:*
is implicit). Even simpler -- just in case the server doesn't like and-ingSEARCH
terms together at all -- would be:and logically doing the AND in your code.
The brute-force way of doing it is:
and then picking out all the ones with neither
\Seen
nor\Deleted
. (I'm suggestingUID FETCH
because a similarFETCH
command will returnBAD
on an empty folder.)Also, you're not supposed to call the
STATUS
command on the currently-selected folder: