I have an IMAP mailbox on Outlook.com/ExchangeOnLine that has about 38,000 messages in it. It is a journaling mailbox, which I am using PHP and Webklex PHP-IMAP to download messages, store in a database, and then delete the message from the mailbox. I noticed that some of the oldest emails are not processed. The oldest emails are 4 emails from January 18 2023.
When I run this Webklex/PHP-IMAP query, I get messages dated about 1/25/2023 and after:
$query->leaveUnread();
$messages = $query->all()->limit($limit = 100, $page = 1)->get(); // This does NOT retrieve the 4 emails from 1/18/2023, but 1/25/2023 and later
However, as mentioned, there are messages in the mailbox, marked unread, which I can see in Outlook.com. They go back to 1/18/2023. If I run this query, then I get the missing messages (the oldest ones):
$messages = $query->before( '2023-01-19')->softFail()->limit($limit = 100 )->get(); // This retrieves the 4 emails from 1/18/2023
The sort order is 'asc', and emails are being iterated oldest to newest.
My question is, why do I not get the emails between 1/18 and 1/24 when I do 'all'?
I have tried various generic filters and orders, such as 'ASC', old(), softfail(), and where(). The only time that the older emails (from 1/18/2023) show up is if I do something like search for the exact subject, or use the before() method indicating prior to 1/19/2023.