php-imap
php-imap copied to clipboard
Folder overview
Describe the bug Multiple call to folder overview result in blocked script
Used config
Code to Reproduce The troubling code section which produces the reported bug.
$cm = new \Webklex\PHPIMAP\ClientManager();
$config = [
'host' => 'outlook.office365.com',
'port' => 993,
'encryption' => 'ssl', // 'tls',
'validate_cert' => true,
'username' => USERNAME,
'password' => ACCESSTOKEN,
'protocol' => 'imap',
'authentication' => "oauth",
];
$client = $cm->make($config);
$client->connect();
$folder = $client->getFolderByPath('INBOX');
updateMail($folder);
echo 'OK';
function updateMail($folder, $treshold, $pagination)
{
$overview = $folder->overview('42:52');
$overview = $folder->overview('31:41');
$overview = $folder->overview('20:30');
$overview = $folder->overview('9:19');
$overview = $folder->overview('1:8');// 5fth call got blocked even with different sequence
}
Expected behavior work for an arbitrary number of calls
Screenshots If applicable, add screenshots to help explain your problem.
Desktop / Server (please complete the following information):
- OS: [Windows 11]
- PHP: [e.g. 7.4.29]
- Version [v4.0.2]
- Provider [Outlook]
Additional context Add any other context about the problem here.
Hi @sviluppo-magicleader , many thanks for the detailed report. This sounds like you are getting rate limited by your email provider. Do you experience the same issue if you delay those requests?
Best regards,
I tried this
$overview = $folder->overview('42:52');
sleep(10);
$overview = $folder->overview('31:41');
sleep(10);
$overview = $folder->overview('20:30');
sleep(10);
$overview = $folder->overview('9:19');
sleep(10);
$overview = $folder->overview('1:8');
sleep(10);
same result.
I will use
$query->all()->limit($message_number, $page_number)->get();
for now.
My email provider is Microsoft 365 in cloud and I also tried with an Exchange 2016 server on-premise.