imap_search限制返回的消息数 [英] imap_search limit the number of messages returned

查看:48
本文介绍了imap_search限制返回的消息数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有PHP脚本,可以从邮箱中获取消息.我使用imap_search函数: $ emails = imap_search($ mbox,'UNSEEN');

I have PHP script that fetch messages from a mailbox. I use the imap_search function: $emails = imap_search($mbox, 'UNSEEN');

是否有一种方法来限制返回的消息数.现在,在巨大的邮箱上,我收到5000条消息.我只希望按日期排序的前20名.

Is there a way to limit the number of returned messages. Right now on huge mailboxes i get like 5000 messages. I want only the top 20 ordered by date.

有办法吗?

谢谢.

推荐答案

imap_search函数具有CRITERIA属性,可用于通过多种方式限制消息:

The imap_search function has a CRITERIA attribute you can use to limit the messages in a number of ways:

ALL-返回所有符合其他条件的邮件
ANSWERED-匹配带有\ ANSWERED标志集的邮件
密件抄送字符串"-将邮件与密件抄送"字段中的字符串"相匹配
在日期"之前-将消息与日期"匹配:在日期"之前
正文字符串"-匹配邮件正文中带有字符串"的邮件
CC字符串"-在抄送:"字段中将消息与字符串"相匹配
已删除-匹配已删除的邮件
标记-使用\ FLAGGED(有时称为重要"或紧急")标记集匹配邮件
FROM"string"-在发件人:字段中将消息与"string"匹配
关键字字符串"-匹配以字符串"为关键字的邮件
新-匹配新邮件
OLD-匹配旧邮件
ON"date"-匹配带Date的消息:匹配"date"
最近-匹配带有\ RECENT标志设置的邮件
SEEN-匹配已读取的邮件(已设置\ SEEN标志)
自日期"开始-将消息与日期"匹配:日期"之后
主题字符串"-匹配主题中带有字符串"的邮件:
TEXT字符串"-匹配文本为字符串"的邮件
TO"string"-匹配To中带有"string"的消息:UNANSWERED-匹配未答复的邮件
未删除-匹配未删除的邮件
已取消签名-匹配未标记的邮件
UNKEYWORD字符串"-匹配不包含关键字字符串"的邮件
UNSEEN-匹配尚未阅读的邮件

ALL - return all messages matching the rest of the criteria
ANSWERED - match messages with the \ANSWERED flag set
BCC "string" - match messages with "string" in the Bcc: field
BEFORE "date" - match messages with Date: before "date"
BODY "string" - match messages with "string" in the body of the message
CC "string" - match messages with "string" in the Cc: field
DELETED - match deleted messages
FLAGGED - match messages with the \FLAGGED (sometimes referred to as Important or Urgent) flag set
FROM "string" - match messages with "string" in the From: field
KEYWORD "string" - match messages with "string" as a keyword
NEW - match new messages
OLD - match old messages
ON "date" - match messages with Date: matching "date"
RECENT - match messages with the \RECENT flag set
SEEN - match messages that have been read (the \SEEN flag is set)
SINCE "date" - match messages with Date: after "date"
SUBJECT "string" - match messages with "string" in the Subject:
TEXT "string" - match messages with text "string"
TO "string" - match messages with "string" in the To : UNANSWERED - match messages that have not been answered
UNDELETED - match messages that are not deleted
UNFLAGGED - match messages that are not flagged
UNKEYWORD "string" - match messages that do not have the keyword "string"
UNSEEN - match messages which have not been read yet

这篇关于imap_search限制返回的消息数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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