Can you try this for me?
<?php
$mbox = imap_open("{localhost}", $USERMAIL, $PASSMAIL, OP_HALFOPEN)
or die("Can't Connect: " . imap_last_error());
$status = imap_status($mbox, "{localhost}INBOX", SA_ALL);
if ($status) {
echo "Messages: " . $status->messages . "<br />\n";
echo...