The information returned through the parameters is:
- $numMessages = number of not deleted messages in the selected mailbox
- $sizeMessages = sum of the not deleted messages sizes
- $recent = number of recent and not deleted messages
- $unseen = number of unseen and not deleted messages
Before calling this method, a connection to the IMAP server must be
established and a user must be authenticated successfully, and a mailbox
must be selected.
Example of returning the status of the currently selected mailbox:
$imap = new ezcMailImapTransport( 'imap.example.com' );
$imap->authenticate( 'username', 'password' );
$imap->selectMailbox( 'Inbox' );
$imap->status( $numMessages, $sizeMessages, $recent, $unseen );
After running the above code, $numMessages, $sizeMessages, $recent
and $unseen will be populated with values. public function testAppend() { $imap = new ezcMailImapTransport(self::$server, self::$port); $imap->authenticate(self::$user, self::$password); $imap->createMailbox("Guybrush"); $mail = new ezcMail(); $mail->from = new ezcMailAddress('*****@*****.**', 'Marty McFly'); $mail->addTo(new ezcMailAddress('*****@*****.**', 'Doc')); $mail->subject = "Do not open until 1985"; $mail->body = new ezcMailText("NOBODY calls me a chicken!"); $data = $mail->generate(); $imap->append("Guybrush", $data); $imap->append("Guybrush", $data, array('Answered')); $imap->selectMailbox("Guybrush"); $imap->status($numMessages, $sizeMessages); $imap->selectMailbox("Inbox"); $imap->deleteMailbox("Guybrush"); $this->assertEquals(2, $numMessages); }
<?php require_once 'tutorial_autoload.php'; // Create a new IMAP transport object by specifying the server name $imap = new ezcMailImapTransport("imap.example.com"); // Authenticate to the IMAP server $imap->authenticate("user", "password"); // Select the Inbox mailbox $imap->selectMailbox('Inbox'); // Get the number of messages on the server, combined size, number of recent // messages and number of unseen messages // in the variables $num, $size, $recent, $unseen $imap->status($num, $size, $recent, $unseen); // Get the list of message numbers on the server and their sizes // the returned array is something like: array( 1 => 1500, 2 => 45200 ) // where the key is a message number and the value is the message size $messages = $imap->listMessages(); // Get the list of message unique ids on the server and their sizes // the returned array is something like: array( 1 => '15', 2 => '16' ) // where the key is an message number and the value is the message unique id $messages = $imap->listUniqueIdentifiers(); // Usually you will call one of these fetch functions: // Fetch all messages on the server $set = $imap->fetchAll(); // Fetch one message from the server (here: get the message no. 2) $set = $imap->fetchByMessageNr(2); // Fetch a range of messages from the server (here: get 4 messages starting from message no. 2) $set = $imap->fetchFromOffset(2, 4); // Fetch messages which have a certain flag // See the function description for a list of supported flags $set = $imap->fetchByFlag("DELETED");