I haven't worked with before Zend_Mail_Storage_Imap, but from what I can extract from the source, this should do the trick:
function folderExists(Zend_Mail_Storage_Imap $imapObj, $folder) {
try {
$imapObj->selectFolder($folder);
} catch (Zend_Mail_Storage_Exception $e) {
return false;
}
return true;
}
If you want to save the current folder through a check, this is, of course, a little more complicated:
function folderExists(Zend_Mail_Storage_Imap $imapObj, $folder) {
$result = true;
$oldFolder = $imapObj->getCurrentFolder();
try {
$imapObj->selectFolder($folder);
} catch (Zend_Mail_Storage_Exception $e) {
$result = false;
}
$imapObj->selectFolder($oldFolder);
return $result;
}
( , , , , , .)