Seems like you have the true/false result right there!
Valid users return "true".
Invalid users return the error.
Instead of allowing the error to happen, test the imap_open function for success:
if (@imap_open(...yadda...)) { success; }
else { failure; }
Possibly more simple:
$mbox = imap_open(...yadda...) || failure;
Hope this helps...