Search code examples
phpimap

PHP ddeboer/imap $mailbox->getMessages() with UID higher than x


I am using ddeboer/imap (https://github.com/ddeboer/imap) in PHP.

The industry standard of an IMAP client checking mail is to:

  1. save the uidvalidity of a mailbox
  2. save the highest UID fetched from this mailbox
  3. Then, next time you fetch emails, check whether uidvalidity is unchanged and if yes, request to get all messages with a higher UID than what you saved as the highest UID you already have. (If uidvalidity changed, fetch all messages again.)

This makes sure you will not miss out on messages.

Anyway, I can't find a way how I can do a $mailbox->getMessages() with UID as search criteria.


Solution

  • Ok, after several hours of searching, I found it in the source code:

    $messages = $mailbox->getMessageSequence('13900:*');