The resource object that is "$mbox" isn't what you expect it to be. So wherever you create $mbox for that particular mailbox, it's failing. Something is going wrong. Could be a username and password issue, could be an options issue.
If the user changes their password, does your script get updated automatically? If not, then you need to have your script updated each time they do. Otherwise, the login fails and $mbox isn't a resource, but is "false".
You can check to see if the imap login worked by doing:
$mbox = imap_connect('{imap.domain.tld:443}INBOX', 'username', 'password');
if(!is_resource($mbox))
die('Failed to connect!');
Note also that you could cut out a line in your code if you add an option to the imap_connect() line:
$mbox = imap_connect('{imap.domain.tld:443}INBOX', 'username', 'password', CL_EXPUNGE);
if(!is_resource($mbox))
die('IMAP login failed for "username"');
imap_delete($mbox,'1:*');
@imap_close($mbox);
The "CL_EXPUNGE" will automatically expunge the mailbox upon exit. Just an option, not a requirement.