列出所有目录:
$host = '{imap.mail.yahoo.com:993/ssl}';
$user = 'user@yahoo.com';
$pass = 'password';
$inbox = imap_open($host, $user, $pass);
$mailboxes = imap_list($inbox, $host, '*');
$mailboxes = str_replace($host, '', $mailboxes);
print_r($mailboxes);结果:
Array
(
    [0] => Bulk Mail
    [1] => Draft
    [2] => Inbox
    [3] => Sent
    [4] => Trash
)重新打开指定的目录:
imap_reopen($inbox, $host.'Bulk Mail');
$emails = imap_search($inbox,'ALL');
print_r($emails);