ezcMailImapTransport::fetchAll PHP Method

fetchAll() public method

This method supports unique IDs instead of message numbers. See {@link ezcMailImapTransportOptions} for how to enable unique IDs referencing. If $deleteFromServer is set to true the mail will be marked for deletion after retrieval. If not it will be left intact. The set returned can be parsed with {@link ezcMailParser}. 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: $imap = new ezcMailImapTransport( 'imap.example.com' ); $imap->authenticate( 'username', 'password' ); $imap->selectMailbox( 'Inbox' ); $set = $imap->fetchAll(); parse $set with ezcMailParser $parser = new ezcMailParser(); $mails = $parser->parseMail( $set ); foreach ( $mails as $mail ) { process $mail which is an ezcMail object }
public fetchAll ( boolean $deleteFromServer = false ) : ezcMailParserSet
$deleteFromServer boolean
return ezcMailParserSet
    public function fetchAll($deleteFromServer = false)
    {
        if ($this->options->uidReferencing) {
            $messages = array_values($this->listUniqueIdentifiers());
        } else {
            $messages = array_keys($this->listMessages());
        }
        return new ezcMailImapSet($this->connection, $messages, $deleteFromServer, array('uidReferencing' => $this->options->uidReferencing));
    }

Usage Example

コード例 #1
0
 public function testUidCommandsFetchAll()
 {
     $imap = new ezcMailImapTransport(self::$server, self::$port, array('uidReferencing' => true));
     $imap->authenticate(self::$user, self::$password);
     $imap->selectMailbox('inbox');
     $set = $imap->fetchAll();
     $this->assertEquals(array(self::$ids[0], self::$ids[1], self::$ids[2], self::$ids[3]), $set->getMessageNumbers());
     $parser = new ezcMailParser();
     $mails = $parser->parseMail($set);
     $this->assertEquals(4, count($mails));
 }
All Usage Examples Of ezcMailImapTransport::fetchAll