javanile / php-imap2

PHP IMAP with OAUTH2
https://php-imap2.javanile.org/
GNU General Public License v3.0
48 stars 28 forks source link

Trying to access array offset on value of type bool on imap2_num_msg #37

Open gabriel-tandil opened 1 year ago

gabriel-tandil commented 1 year ago

Hello! Nice project, very useful. I am having this problem on one connection (office365) other hotmail connections are working fine. Trying to access array offset on value of type bool

#0 /var/www/html/ver2/vendor/javanile/php-imap2/src/Mailbox.php(54): yii\web\ErrorHandler->handleError('8', ''Trying to acce...', ''/var/www/html/...', '54', '['imap' => clas...') 
#1 /var/www/html/ver2/vendor/javanile/php-imap2/bootstrap.php(391): Javanile\Imap2\Mailbox::numMsg('class Javanile\\...') 
#2 /var/www/html/ver2/common/clasespropias/mails/ClienteMailImap2.php(208): ::imap2_num_msg('class Javanile\\...')

apparently $status is false at MailBox.php line 54

    public static function numMsg($imap)
    {
        if (!is_a($imap, Connection::class)) {
            return Errors::invalidImapConnection(debug_backtrace(), 1, false);
        }

        $imap->selectMailbox();
        $client = $imap->getClient();

        $status = $client->status($imap->getMailboxName(), ['MESSAGES']);

        return intval($status['MESSAGES']);
    }
gabriel-tandil commented 1 year ago

I didn't get to analyze the ins and outs of the problem but it happened with an office365 account when in the connection string I passed the mailbox name (INBOX) {outlook.office365.com:993/imap/ssl/novalidate-cert}INBOX but this way it worked fine with @hotmail.com account Without the mailbox name it works fine with the o365 account but not with the hotmail account.