I am using ddeboer/imap (https://github.com/ddeboer/imap) in PHP.
The industry standard of an IMAP client checking mail is to:
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.
Ok, after several hours of searching, I found it in the source code:
$messages = $mailbox->getMessageSequence('13900:*');