(PHP 4, PHP 5, PHP 7, PHP 8)

imap_mailboxmsginfoObtener información sobre el buzón actual


imap_mailboxmsginfo(resource $imap_stream): object

Comprueba el estado del buzón actual del servidor. Es similar a imap_status(), excepto que resumirá el tamaño de todos los mensajes del buzón, lo que tomará algún tiempo adicional para ejecutarse.



IMAP stream devuelto por imap_open().

Valores devueltos

Devuelve la información en un objeto con las siguientes propiedades:

Propiedades del buzón
Date fecha del último cambio (fecha/hora actuales)
Driver controlador
Mailbox nombre del buzón
Nmsgs número de mensajes
Recent número de mensajes recientes
Unread número de mensajes no leídos
Deleted número de mensajes eliminados
Size tamaño del buzón

Devuelve false en caso de error.


Ejemplo #1 Ejemplo de imap_mailboxmsginfo()


      or die(
"no se puede conectar: " imap_last_error());

$comprobar imap_mailboxmsginfo($buzón);

if (
$comprobar) {
"Fecha: "       $comprobar->Date    "<br />\n" ;
"Controlador: " $comprobar->Driver  "<br />\n" ;
"Buzón: "       $comprobar->Mailbox "<br />\n" ;
"Mensajes: "    $comprobar->Nmsgs   "<br />\n" ;
"Recientes: "   $comprobar->Recent  "<br />\n" ;
"No leídos: "   $comprobar->Unread  "<br />\n" ;
"Eliminados: "  $comprobar->Deleted "<br />\n" ;
"Tamaño: "      $comprobar->Size    "<br />\n" ;
} else {
"Falló imap_mailboxmsginfo(): " imap_last_error() . "<br />\n";



add a note add a note

User Contributed Notes 6 notes

js at jerntorget dot se, ej at jerntorget dot se
20 years ago
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);
12 years ago
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.
18 years ago
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)
m at tacker dot org
19 years ago
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 **/

workshop200 dot com at gmail dot com
4 years ago
If you need to get only time for the mailbox you should go with imap_check()
stephane-wantiez at tiscalinet dot be
20 years ago
imap_get_quota need you to be the admin of the mail server !
To Top