imap_search limit the number of messages returned
问题 I have PHP script that fetch messages from a mailbox. I use the imap_search function: $emails = imap_search($mbox, 'UNSEEN'); 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. Is there a way to do that? Thanks. 回答1: The imap_search function has a CRITERIA attribute you can use to limit the messages in a number of ways: ALL - return all messages matching the rest of the criteria ANSWERED -