ddeboer / imap

Object-oriented, fully tested PHP IMAP library
MIT License
887 stars 253 forks source link

Running into intermittent "Cannot reopen mailbox XYZ" #551

Open fresent opened 1 year ago

fresent commented 1 year ago

ddeboer/imap version : 1.14.2 PHP version : 8.0 IMAP provider : Outlook, Hotmail and cPanel

Only for Outlook/Hotmail and cPanel based IMAP (ESP) the service seems to be spitting "Cannot reopen mailbox XYZ" intermittently.

$server = new Server($hostname, $port, flags:'/imap/ssl/novalidate-cert', retries:2);
$connection = $server->authenticate($username, $password);
$allMailboxes = $connection->getMailboxes();
foreach ($allMailboxes as $mailbox) {
        if($mailboxTobeFound == $mailbox->getName()){
               $today = new \DateTimeImmutable();
               $cutOffDaysAgo = $today->sub(new \DateInterval('P'.$cutOffDays.'D'));
               $search = new SearchExpression();
               $search->addCondition(new \Ddeboer\Imap\Search\Text\Subject('subject filter'));
               $search->addCondition(new \Ddeboer\Imap\Search\Date\Before($cutOffDaysAgo));
               $allMessages = $mailbox->getMessages($search);
        }
}

The tested outlook/hotmail were on free version, and not on enterprise version of microsoft email.

necmettin commented 1 year ago

I have the same problem with Office365 accounts.

imzhi commented 11 months ago

I have the same problem with 163 email