ddeboer / imap

Object-oriented, fully tested PHP IMAP library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Running into intermittent "Cannot reopen mailbox XYZ"

fresent opened this issue · comments

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.

I have the same problem with Office365 accounts.

I have the same problem with 163 email