php-imap icon indicating copy to clipboard operation
php-imap copied to clipboard

Folder overview

Open sviluppo-magicleader opened this issue 3 years ago • 2 comments

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.

sviluppo-magicleader avatar Sep 16 '22 14:09 sviluppo-magicleader

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,

Webklex avatar Sep 19 '22 01:09 Webklex

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.

sviluppo-magicleader avatar Sep 19 '22 07:09 sviluppo-magicleader