sortMessages() public method

This method supports unique IDs instead of message numbers. See {@link ezcMailImapTransportOptions} for how to enable unique IDs referencing. $messages is an array of message numbers, for example: array( 1, 2, 4 ); $sortCriteria is an email header like: Subject, To, From, Date, Sender, etc. 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( 'mailbox' ); // Inbox or another mailbox Fetch the list of messages sorted by Date $set = $imap->sortMessages( 1, 10, "Date" ); $set can be parsed with ezcMailParser
public sortMessages ( array(int) $messages, string $sortCriteria, boolean $reverse = false ) : ezcMailImapSet
$messages array(int)
$sortCriteria string
$reverse boolean
return ezcMailImapSet
Ejemplo n.º 1
0
 public function testSortWithPeek()
 {
     $imap = new ezcMailImapTransport(self::$server, self::$port);
     $imap->authenticate(self::$user, self::$password);
     $imap->createMailbox("Guybrush");
     $imap->selectMailbox("Inbox");
     $imap->copyMessages("1,2", "Guybrush");
     $imap->selectMailbox("Guybrush");
     $imap->clearFlag("1,2", "SEEN");
     $this->assertEquals(0, $imap->countByFlag("SEEN"));
     $src = $imap->sortMessages(array(1, 2), "Subject");
     $this->assertEquals(0, $imap->countByFlag("SEEN"));
     $imap->selectMailbox("Inbox");
     $imap->deleteMailbox("Guybrush");
 }
Ejemplo n.º 2
0
 public function testUidSortMessagesNotSelected()
 {
     $imap = new ezcMailImapTransport(self::$server, self::$port, array('uidReferencing' => true));
     $imap->authenticate(self::$user, self::$password);
     try {
         $imap->sortMessages(array(self::$ids[0], self::$ids[1], self::$ids[2], self::$ids[3]), 'subject');
         $this->fail("Expected exception was not thrown.");
     } catch (ezcMailTransportException $e) {
     }
 }
Ejemplo n.º 3
0
// 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");
// Fetch a range of messages sorted by Date
// Use this to page through a mailbox
// See the function description for a list of criterias and for how to sort ascending or descending
$set = $imap->sortFromOffset(1, 10, "Date");
// Sort the specified messages by Date
// See the function description for a list of criterias and for how to sort ascending or descending
$set = $imap->sortMessages("1,2,3,4,5", "Date");
// Fetch messages which match the specified criteria.
// See the section 6.4.4. of RFC 1730 or 2060 for a list of criterias
// (http://www.faqs.org/rfcs/rfc1730.html)
// The following example returns the messages flagged as SEEN and with
// 'release' in their Subject
$set = $imap->searchMailbox('SEEN SUBJECT "release"');
// Delete a message from the server (message is not physically deleted, but it's
// list of flags get the "Deleted" flag.
$imap->delete(1);
// Use this to permanently delete the messages flagged with "Deleted"
$imap->expunge();
// Use this to keep the connection alive
$imap->noop();
// Create a new mail parser object
$parser = new ezcMailParser();