imap_check throwing notice when mailbox is empty
imap, php
Solution
I just discovered that calling the imap_errors() function suppresses the notice exception.
So the only thing you need to do is add this somewhere in your code:
$errors = imap_errors();
What you do with the $errors variable afterwards is up to you.
Problem
So I've recently started my first real job (yay!) and I'm working on an email checker. It's working great, no errors... provided there are emails. ``` $mbox = imap_open("{.../pop3/novalidate-cert}INBOX","smith@example.com","..."); $inbox = imap_check($mbox); ``` The above code works just fine when there are emails in the inbox, but if there aren't I get this error at the end of the page: Notice: Unknown: Mailbox is empty (errflg=1) in Unknown on line 0 No amount of error suppression seems to be able to stop this from being thrown, other than `error_reporting(E_ALL^E_NOTICE)`, which I'd rather not use (for once!) Can anything be done?