barbushin / php-imap

Manage mailboxes, filter/get/delete emails in PHP (supports IMAP/POP3/NNTP)
MIT License
1.66k stars 457 forks source link

Error Handling Not working #713

Open iamved777 opened 1 year ago

iamved777 commented 1 year ago

Hi! I have checked various issues in issues section but not found proper method for handle errors.

try {

    $mailbox = new Mailbox($hoststring, 'example@gmail.com', "adadadaadaadd", false);
    try {
        $mail_ids = $mailbox->searchMailbox('ALL');
    } catch (ConnectionException $ex) {
       $error = $ex->getMessage();
        echo $error;
    } catch (Exception $ex) {
        $error = $ex->getMessage();
        echo $error;
    }

 }catch (ConnectionException $ex) {
        $error = $ex->getMessage();
        echo $error;

    }catch (Exception $ex) {
        $error = $ex->getMessage();
        echo $error;

}

Its never echo error but instead giving fatal error on invalid password etc, Let me know if I am missing anything in this. Thanks!