setConnectionArgs( CL_EXPUNGE // expunge deleted mails upon mailbox close | OP_SECURE // don't do non-secure authentication ); echo '
';
try {
// Get all emails (messages)
// PHP.net imap_search criteria: http://php.net/manual/en/function.imap-search.php
print_r($mailbox);
$mailsIds = $mailbox->searchMailbox('ALL');
echo $mailsIds;
} catch(PhpImap\Exceptions\ConnectionException $ex) {
echo "IMAP connection failed: " . implode(",", $ex->getErrors('all'));
die();
}
// If $mailsIds is empty, no emails could be found
if(!$mailsIds) {
die('Mailbox is empty');
}
echo 111;