PHP.nl

imap_status

imap_status

Returns status information on a mailbox

 **imap_status** IMAP\Connection $imap string $mailbox int $flags

Gets status information about the given . mailbox

mailbox The mailbox name, see for more information imap_open

flags Valid flags are:

  - - set  to the           number of messages in the mailbox          `SA_MESSAGES``$status->messages`
    • set to the number of recent messages in the mailbox SA_RECENT``$status->recent
    • set to the number of unseen (new) messages in the mailbox SA_UNSEEN``$status->unseen
    • set to the next uid to be used in the mailbox SA_UIDNEXT``$status->uidnext
    • set to a constant that changes when uids for the mailbox may no longer be valid SA_UIDVALIDITY``$status->uidvalidity
    • set all of the above SA_ALL

    This function returns an object containing status information, return.falseforfailure. The object has the following properties: , , , , and .
    messages``recent``unseen``uidnext``uidvalidity

    is also set, which contains a bitmask which can be checked against any of the above constants. flags

    Voorbeeld: example

<?php
$mbox = imap_open("{imap.example.com}", "username", "password", OP_HALFOPEN)
      or die("can't connect: " . imap_last_error());

$status = imap_status($mbox, "{imap.example.org}INBOX", SA_ALL);
if ($status) {
  echo "Messages:   " . $status->messages    . "<br />\n";
  echo "Recent:     " . $status->recent      . "<br />\n";
  echo "Unseen:     " . $status->unseen      . "<br />\n";
  echo "UIDnext:    " . $status->uidnext     . "<br />\n";
  echo "UIDvalidity:" . $status->uidvalidity . "<br />\n";
} else {
  echo "imap_status failed: " . imap_last_error() . "\n";
}

imap_close($mbox);
?>