src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
public function listMessages( $contentType = null )
    {
        if ( $this->state != self::STATE_SELECTED &&
             $this->state != self::STATE_SELECTED_READONLY )
        {
            throw new ezcMailTransportException( "Can't call listMessages() on the IMAP transport when a mailbox is not selected." );
        }

        $messageList = array();
        $messages = array();
 
        // get the numbers of the existing messages
        $tag = $this->getNextTag();
        $command = "{$tag} SEARCH UNDELETED";
        if ( !is_null( $contentType ) )
        {
            $command .= " HEADER \"Content-Type\" \"{$contentType}\"";
        }
        $this->connection->sendData( $command );
        $response = trim( $this->getResponse( '* SEARCH' ) );
        if ( strpos( $response, '* SEARCH' ) !== false )
        {
            $ids = trim( substr( $response, 9 ) );
            if ( $ids !== "" )
            {
                $messageList = explode( ' ', $ids );
            }
        }
        // skip the OK response ("{$tag} OK Search completed.")
        $response = trim( $this->getResponse( $tag, $response ) );
        if ( $this->responseType( $response ) != self::RESPONSE_OK )
        {
            throw new ezcMailTransportException( "The IMAP server could not list messages: {$response}." );
        }

        if ( !empty( $messageList ) )
        {
            // get the sizes of the messages
            $tag = $this->getNextTag();
            $query = trim( implode( ',', $messageList ) );
            $this->connection->sendData( "{$tag} FETCH {$query} RFC822.SIZE" );
            $response = $this->getResponse( 'FETCH (' );
            $currentMessage = trim( reset( $messageList ) );
            while ( strpos( $response, 'FETCH (' ) !== false )
            {
                $line = $response;
                $line = explode( ' ', $line );
                $line = trim( $line[count( $line ) - 1] );
                $line = substr( $line, 0, strlen( $line ) - 1 );
                $messages[$currentMessage] = intval( $line );
                $currentMessage = next( $messageList );
                $response = $this->connection->getLine();
            }
            // skip the OK response ("{$tag} OK Fetch completed.")
            $response = trim( $this->getResponse( $tag, $response ) );
            if ( $this->responseType( $response ) != self::RESPONSE_OK )
            {
                throw new ezcMailTransportException( "The IMAP server could not list messages: {$response}." );
            }
        }
        return $messages;
    }
public function listMessages( $contentType = null )
    {
        if ( $this->state != self::STATE_SELECTED &&
             $this->state != self::STATE_SELECTED_READONLY )
        {
            throw new ezcMailTransportException( "Can't call listMessages() on the IMAP transport when a mailbox is not selected." );
        }

        $messageList = array();
        $messages = array();
 
        // get the numbers of the existing messages
        $tag = $this->getNextTag();
        $command = "{$tag} SEARCH UNDELETED";
        if ( !is_null( $contentType ) )
        {
            $command .= " HEADER \"Content-Type\" \"{$contentType}\"";
        }
        $this->connection->sendData( $command );
        $response = trim( $this->getResponse( '* SEARCH' ) );
        if ( strpos( $response, '* SEARCH' ) !== false )
        {
            $ids = trim( substr( $response, 9 ) );
            if ( $ids !== "" )
            {
                $messageList = explode( ' ', $ids );
            }
        }
        // skip the OK response ("{$tag} OK Search completed.")
        $response = trim( $this->getResponse( $tag, $response ) );
        if ( $this->responseType( $response ) != self::RESPONSE_OK )
        {
            throw new ezcMailTransportException( "The IMAP server could not list messages: {$response}." );
        }

        if ( !empty( $messageList ) )
        {
            // get the sizes of the messages
            $tag = $this->getNextTag();
            $query = trim( implode( ',', $messageList ) );
            $this->connection->sendData( "{$tag} FETCH {$query} RFC822.SIZE" );
            $response = $this->getResponse( 'FETCH (' );
            $currentMessage = trim( reset( $messageList ) );
            while ( strpos( $response, 'FETCH (' ) !== false )
            {
                $line = $response;
                $line = explode( ' ', $line );
                $line = trim( $line[count( $line ) - 1] );
                $line = substr( $line, 0, strlen( $line ) - 1 );
                $messages[$currentMessage] = intval( $line );
                $currentMessage = next( $messageList );
                $response = $this->connection->getLine();
            }
            // skip the OK response ("{$tag} OK Fetch completed.")
            $response = trim( $this->getResponse( $tag, $response ) );
            if ( $this->responseType( $response ) != self::RESPONSE_OK )
            {
                throw new ezcMailTransportException( "The IMAP server could not list messages: {$response}." );
            }
        }
        return $messages;
    }
public function listMessages ( $ contentType = null ) { if ( $ this -> state != self :: STATE_SELECTED && $ this -> state != self :: STATE_SELECTED_READONLY ) { throw new ezcMailTransportException ( "Can't call listMessages() on the IMAP transport when a mailbox is not selected." ) ; } $ messageList = array ( ) ; $ messages = array ( ) ; // get the numbers of the existing messages $ tag = $ this -> getNextTag ( ) ; $ command = "{$tag} SEARCH UNDELETED" ; if ( ! is_null ( $ contentType ) ) { $ command .= " HEADER \"Content-Type\" \"{$contentType}\"" ; } $ this -> connection -> sendData ( $ command ) ; $ response = trim ( $ this -> getResponse ( '* SEARCH' ) ) ; if ( strpos ( $ response , '* SEARCH' ) !== false ) { $ ids = trim ( substr ( $ response , 9 ) ) ; if ( $ ids !== "" ) { $ messageList = explode ( ' ' , $ ids ) ; } } // skip the OK response ("{$tag} OK Search completed.") $ response = trim ( $ this -> getResponse ( $ tag , $ response ) ) ; if ( $ this -> responseType ( $ response ) != self :: RESPONSE_OK ) { throw new ezcMailTransportException ( "The IMAP server could not list messages: {$response}." ) ; } if ( ! empty ( $ messageList ) ) { // get the sizes of the messages $ tag = $ this -> getNextTag ( ) ; $ query = trim ( implode ( ',' , $ messageList ) ) ; $ this -> connection -> sendData ( "{$tag} FETCH {$query} RFC822.SIZE" ) ; $ response = $ this -> getResponse ( 'FETCH (' ) ; $ currentMessage = trim ( reset ( $ messageList ) ) ; while ( strpos ( $ response , 'FETCH (' ) !== false ) { $ line = $ response ; $ line = explode ( ' ' , $ line ) ; $ line = trim ( $ line [ count ( $ line ) - 1 ] ) ; $ line = substr ( $ line , 0 , strlen ( $ line ) - 1 ) ; $ messages [ $ currentMessage ] = intval ( $ line ) ; $ currentMessage = next ( $ messageList ) ; $ response = $ this -> connection -> getLine ( ) ; } // skip the OK response ("{$tag} OK Fetch completed.") $ response = trim ( $ this -> getResponse ( $ tag , $ response ) ) ; if ( $ this -> responseType ( $ response ) != self :: RESPONSE_OK ) { throw new ezcMailTransportException ( "The IMAP server could not list messages: {$response}." ) ; } } return $ messages ; }
Returns a list of the not deleted messages in the current mailbox.

It returns only the messages with the flag DELETED not set.

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.

The format of the returned array is
<code>
array( message_id => size );
</code>

Example:
<code>
array( 2 => 1700, 5 => 1450, 6 => 21043 );
</code>

If $contentType is set, it returns only the messages with
$contentType in the Content-Type header.

For example $contentType can be "multipart/mixed" to return only the
messages with attachments.

@throws ezcMailTransportException
if a mailbox is not selected
or if the server sent a negative response
@param string $contentType
@return array(int)
Returns a list of the not deleted messages in the current mailbox .