This method supports unique IDs instead of message numbers. See
{@link ezcMailImapTransportOptions} for how to enable unique IDs
referencing.
If the command failed or if it was not supported by the server an empty
string is returned.
This method is useful for retrieving the headers of messages from the
mailbox as strings, which can be later parsed with {@link ezcMailParser}
and {@link ezcMailVariableSet}. In this way the retrieval of the full
messages from the server is avoided when building a list of 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 listing the mail headers of all the messages in the current
mailbox:
$imap = new ezcMailImapTransport( 'imap.example.com' );
$imap->authenticate( 'username', 'password' );
$imap->selectMailbox( 'Inbox' );
$parser = new ezcMailParser();
$messages = $imap->listMessages();
foreach ( $messages as $messageNr => $size )
{
$set = new ezcMailVariableSet( $imap->top( $messageNr ) );
$mail = $parser->parseMail( $set );
$mail = $mail[0];
echo "From: {$mail->from}, Subject: {$mail->subject}, Size: {$size}\n";
}
For a more advanced example see the "Mail listing example" in the online
documentation.