Search code examples
phpimap

PHP imap - get the maximum capacity of mailbox


In my gmail account, for example, I cannot have more than 15Gb of messages. Is there a way to retrieve this number somehow with php's imap functions?

I know there is imap_mailboxmsginfo(), which will tell me how much of memory I am using right now (350MB, for example), but it doesn't say that 15GB is the maximum, that's the problem..


Solution

  • Yes, you may achieve it with the following code of lines : May be it can help to you. Can you please try it once?

    array imap_get_quota ( resource $imap_stream , string $quota_root );
    $mbox = imap_open("{imap.example.org}", "mailadmin", "password", OP_HALFOPEN)
      or die("can't connect: " . imap_last_error());
    
    $quota_values = imap_get_quota($mbox, "user.kalowsky");
    
    if (is_array($quota_values)) {
       $storage = $quota_values['STORAGE'];
       echo "STORAGE usage level is: " .  $storage['usage'];
       echo "STORAGE limit level is: " .  $storage['limit'];
    
       $message = $quota_values['MESSAGE'];
       echo "MESSAGE usage level is: " .  $message['usage'];
       echo "MESSAGE limit is: " .  $message['limit'];
    
    }