<?php $imbox = imap_open("{imap.site.com:143}", "username", "password"); echo "<h1>Mailboxes</h1>\n"; $folders = imap_listmailbox($imbox, "{imap.site.com:143}", "*"); if ($folders == false) { echo "failed to retrieve folders<br />\n"; } else { foreach ($folders as $val) { echo $val . "<br />\n"; } }