PHP | List all folders in the mailbox

$mbox = imap_open("{mail.example.com:143/novalidate-cert}", "foo@example.com", "password")
	     or die("can't connect: " . imap_last_error());
         
$folders = imap_list($mbox, "{mail.example.com:143/novalidate-cert}", "*");

if ($folders === false) {
    echo "Failed to list folders in mailbox";
} else {
    print_r($folders);
}

imap_close($mbox);

Leave a Comment

Your email address will not be published. Required fields are marked *