Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
function listFolder(){
$mailboxes=imap_list($this->connection,$this->serverName,'*');
if (is_array($mailboxes)) {
foreach ($mailboxes as $mailbox) {
$mailbox=str_replace($this->serverName,'',$mailbox);
echo "$mailbox";
}
} else {
echo "imap_list failed: " . imap_last_error() . "\n";
}
}
Posted
Updated 9-Oct-11 22:41pm
v3

I don't see any mention of foreach here[^].
 
Share this answer
 
Comments
Firo Atrum Ventus 10-Oct-11 3:35am    
It's in php, php DO have a foreach http://php.net/manual/en/control-structures.foreach.php
Richard MacCutchan 10-Oct-11 10:15am    
I wonder where my brain was this morning?
I haven't programmed in php for a long, long time so I can only guess.
Try this :
PHP
$mailboxes=imap_list($this->connection,$this->serverName,'*');
if (is_array($mailboxes)) {
    foreach ($mailboxes as $val) {
        $mailbox=str_replace($this->serverName,'',$mailbox);
        echo "$mailbox";
    }
} else {
    echo "imap_list failed: " . imap_last_error() . "\n";
}

If you get an error, post it here (use Improve question)
 
Share this answer
 
v2
Comments
yornsocheat 10-Oct-11 4:04am    
what is $list? error is "Notice: Undefined variable: list in /var/www/socheat/webmail/php/ClassDefine.php on line 55 imap_list failed:" please help me!
Firo Atrum Ventus 10-Oct-11 4:22am    
My bad, it's $mailboxes
yornsocheat 10-Oct-11 4:43am    
i have update code but it is not error, it return message "imap_list failed:".
is it a array?
Firo Atrum Ventus 10-Oct-11 4:55am    
Well, AFAIK if you got "imap_list failed:" without any additional detail about the error that means there's no mailboxes.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900