ezcMailImapTransport::status PHP Method

status() public method

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 status ( &$numMessages, &$sizeMessages, &$recent, &$unseen ) : boolean
return boolean
    public function status(&$numMessages, &$sizeMessages, &$recent = 0, &$unseen = 0)
    {
        if ($this->state != self::STATE_SELECTED && $this->state != self::STATE_SELECTED_READONLY) {
            throw new ezcMailTransportException("Can't call status() on the IMAP transport when a mailbox is not selected.");
        }
        $messages = $this->listMessages();
        $numMessages = count($messages);
        $sizeMessages = array_sum($messages);
        $messages = array_keys($messages);
        $recentMessages = array_intersect($this->searchByFlag("RECENT"), $messages);
        $unseenMessages = array_intersect($this->searchByFlag("UNSEEN"), $messages);
        $recent = count($recentMessages);
        $unseen = count($unseenMessages);
        return true;
    }

Usage Example

コード例 #1
0
 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);
 }
All Usage Examples Of ezcMailImapTransport::status