On 07/13/2011 05:17 AM, tower wrote:
> Is there any metod to use exim to read current maildir capasity? I
> need to get this integer value in php script and put it somewhere in
> my webmail.
There's nothing that I know of that will cause exim to return quota
information. However, you can get it yourself in PHP with a little
effort. Assuming you are using MailDir++ and have a 'maildirsize'
file. The following will get you there. Or at least get you started
down the path.
if(is_file($filename))
{
$contents = file($filename);
// Drop the first line of the file
array_shift($contents);
// Calculate the current maildir size and number of items.
foreach ($contents as $line)
{
$items = preg_split("/ +/", trim($line));
$totalsize += $items['0'];
$totalfiles += $items['1'];
}
$result['totalsize'] = $totalsize;
$result['totalfiles'] = $totalfiles;
}
else //file not found
{
//Get the data the hard way
$totalsize = exec("du --exclude=\".Trash\" -s $directory");
$totalsize = trim(str_replace($directory, '', $totalsize));
}
Bryan Rawlins
Systems Administrator
OnlyMyEmail Inc.