(PHP 4, PHP 5)

imap_mailboxmsginfoGet information about the current mailbox


object imap_mailboxmsginfo ( resource $imap_stream )

Checks the current mailbox status on the server. It is similar to imap_status(), but will additionally sum up the size of all messages in the mailbox, which will take some additional time to execute.

Список параметров


Поток IMAP, полученный из imap_open().

Возвращаемые значения

Returns the information in an object with following properties:

Mailbox properties
Date date of last change (current datetime)
Driver driver
Mailbox name of the mailbox
Nmsgs number of messages
Recent number of recent messages
Unread number of unread messages
Deleted number of deleted messages
Size mailbox size

Returns FALSE on failure.


Пример #1 imap_mailboxmsginfo() example


      or die(
"can't connect: " imap_last_error());

$check imap_mailboxmsginfo($mbox);

if (
$check) {
"Date: "     $check->Date    "<br />\n" ;
"Driver: "   $check->Driver  "<br />\n" ;
"Mailbox: "  $check->Mailbox "<br />\n" ;
"Messages: " $check->Nmsgs   "<br />\n" ;
"Recent: "   $check->Recent  "<br />\n" ;
"Unread: "   $check->Unread  "<br />\n" ;
"Deleted: "  $check->Deleted "<br />\n" ;
"Size: "     $check->Size    "<br />\n" ;
} else {
"imap_check() failed: " imap_last_error() . "<br />\n";




It is very slow,so don't use it to get mailbox size,used imap_get_quota instead.
2002-01-04 09:35:59
Don't lie... I've timed it, there is merely a time difference, besides it returns a lot of other useful info packed in an object!
2002-01-13 00:57:18
imap_get_quota need you to be the admin of the mail server !
2002-08-11 16:13:21
then use imap_get_quotaroot().....

or use this one (works with qmail):
function get_quotaroot() {
if(!$socket = @fsockopen("your server", your port);
    return false;
fgets($socket, 1024);
fputs($socket, "a001 LOGIN ".$username." ".$password."\n");
fgets($socket, 1024);
fputs($socket, "a002 GETQUOTAROOT INBOX\n");
fgets($socket, 1024);
$result = fgets($socket, 1024);
fputs($socket, "a003 LOGOUT\n");
fgets($socket, 1024);
sscanf($result, '* QUOTA "ROOT" (STORAGE %d %d MESSAGE %d %d', $usedSize, $maxSize, $usedNum, $maxNum);
return array("usedSize" => $usedSize, "maxSize" => $maxSize, "usedNum" => $usedNum, "maxNum" => $maxNum);
2002-09-20 10:29:08
the 'recent' of this function returns the same as 'UIDvalidity' from imap_status() ... makes no sense (or dos it?)
2003-03-03 16:13:21
The runtime difference between imap_status and imap_mailboxmsginfo is very significant on large mailboxes


/** opening connection to a
   * mailbox with 3987 messages
   * and retrive status information **/
$mbox imap_open ('{}'$user$password);

$mbox_info imap_status($mbox'{}INBOX'SA_MESSAGES);
/** took 11.05 seconds **/

$mbox_info imap_mailboxmsginfo($mbox);
/** took 6 minutes 5.382 seconds **/

2003-03-12 03:55:17
About the slowness of imap_mailboxmsginfo() : if used on an IMAP connection, I did checked my mailserver logs and it appeared to send FETCH commands to retrieve the headers of EVERY messages of the mailbox ...
So, if you have, let's say, 400 messages in a folder, the function will be very slow (>1.5 sec on a local server !) ... 

I strongly advise you to use imap_status() instead, which only sends one < STATUS "Mailbox/Name" (MESSAGES UNSEEN) > and is actually a lot faster (at least with IMAP, but that's maybe not true with POP3)
2004-08-30 17:41:54
imap_mailboxmsginfo() is NOT similar to imap_status(). You will easily recognize that if you compare the prototypes:

object imap_mailboxmsginfo  (  resource $imap_stream  )

object imap_status  (  resource $imap_stream  ,  string $mailbox  ,  int $options  )

One SIGNIFICANT difference is that imap_mailboxmsginfo() gets the mailbox name from the stream resource and imap_status() requires any mailbox name as second argument.
2010-03-15 07:32:37
If you need to get only time for the mailbox you should go with imap_check()
2018-01-29 23:55:50

    Поддержать сайт на родительском проекте КГБ