diff --git a/src/Fetch/Server.php b/src/Fetch/Server.php index c5c9ced..883ca0c 100644 --- a/src/Fetch/Server.php +++ b/src/Fetch/Server.php @@ -318,11 +318,18 @@ class Server /** * This returns the number of messages that the current mailbox contains. * + * @param string $mailbox the mailbox path if required to get sub-folder counts * @return int */ - public function numMessages() + public function numMessages( $mailbox='' ) { - return imap_num_msg($this->getImapStream()); + $oldMailbox = $this->getMailBox(); + if( $mailbox !== '' ) { + $this->setMailbox( $mailbox ); + } + $cnt = imap_num_msg($this->getImapStream()); + $this->setMailbox( $oldMailbox ); + return $cnt; } /**