ZF-3095: Zend_Mail_Protocol_Imap::listMailbox - Invalid argument supplied for foreach()

Issue Type: Bug Created: 2008-04-10T16:12:10.000+0000 Last Updated: 2008-09-02T10:39:05.000+0000 Status: Resolved Fix version(s): - 1.6.0 (02/Sep/08)

Reporter: Cole Snodgrass (cole.snodgrass) Assignee: Nico Edtinger (nico) Tags: - Zend_Mail

Related issues: Attachments:


Appears that calling Zend_Mail_Storage_Imap::getFolders with an invalid parameter will cause a PHP warning to be thrown as Zend_Mail_Protocol_Imap will attempt to iterate over a boolean value.

<pre class="highlight">
$mail = new Zend_Mail_Storage_Imap(array(..., 'ssl' => 'SSL'));
$folders = $mail->getFolders('DoesNotExist');

this will eventually end up calling the following code

<pre class="highlight">
    public function listMailbox($reference = '', $mailbox = '*')
        $result = array();
        $list = $this->requestAndResponse('LIST', $this->escapeString($reference, $mailbox));
        if (!$list) {
            return $result;

        foreach ($list as $item) {
            if (count($item) != 4 || $item[0] != 'LIST') {
            $result[$item[3]] = array('delim' => $item[2], 'flags' => $item[1]);

        return $result;

Which will cause a PHP Warning when it tries to loop through $list as $list is a bool(true) and not an array.


Posted by Wil Sinclair (wil) on 2008-04-18T15:48:53.000+0000

Please evaluate and categorize/assign as necessary.

Posted by Nico Edtinger (nico) on 2008-04-22T12:05:14.000+0000

Good catch. It seems a bit strange, that you don't get an error with an invalid reference, but it's now checked.

Posted by Wil Sinclair (wil) on 2008-09-02T10:39:05.000+0000

Updating for the 1.6.0 release.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.