I haven't programmed in php for a long, long time so I can only guess.
Try this :
$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)