Anders Jenbo - 2010-01-06 22:08:40
$size = 0;
$mailsTotal = 0;
//Get full list of mailboxes
$mailboxList = $imap->list_mailbox();
foreach($mailboxList as $mailbox) {
//Open each mailbox
$mailboxStatus = $imap->open_mailbox($mailbox, true);
//Get the number of mails in the mailbox
preg_match('/([0-9]+)\sEXISTS/', $mailboxStatus, $mails);
$mailsTotal += $mails[1];
Get the size of each mail in the mailbox
preg_match_all('/SIZE\s([0-9]+)/', $imap->fetch_mail('1:'.$mails[1].'', 'FAST'), $mailSizes);
$size += array_sum($mailSizes[1]);
}
echo($mailsTotal.' : '.number_format($size/1024/1024, 1, ',', '').'MB');