From 397b748370c8a0a2cf3c457af0d954348284300f Mon Sep 17 00:00:00 2001 From: Lewis Cowles Date: Sat, 23 May 2015 23:10:58 +0100 Subject: [PATCH] can now get number of messages in a sub-folder --- src/Fetch/Server.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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; } /**