Maildir::Quota - Perl extension for Maildir++ soft quotas handling
use Maildir::Quota; sub Maildir::Quota::error { # error handler warn("$_[0]\n"); } my $q = new Maildir::Quota; my $bytes = $q->bytes; my $max_bytes = $q->max_bytes; my $files = $q->files; my $max_files = $q->max_files; if ($q->test($nbytes, $nfiles)) { if ( add the files in the maildir ) { $q->add($nbytes, $nfiles); } } if (... message removed ...) { $q->add(-$message_size, -1); } unless ($q->test) { die "overquota"; } undef $q; # flush quota description
Maildir::Quota is a perl module to edit and check Maildir++ soft quota cache.
Maildir::Quota
Create a Maildir::Quota. It recieve the directory where the Maildir is and a optional quota description.
Quota description are a coma (,) separated list of quota specifications. A quota specification consists of a number, followed by a letter specifying the type of quota. Currently the following quota types are used: S - maximum size of messages in the maildir; C - message count in the maildir.
If quota description is not given, the value is taken from the quota cache file.
Return true if the Maildir can store NFILES messages of a total NBYTES bytes. If NBYTES or NFILES are not defined, check is the Maildir is overquota.
If a Maildir::Quota::error subroutine is defined, all errors are send to it. Maildir not found, invalid or empty quota description are not errors.
Quota file is opened in read-write mode. If cache recalculation occurs, a new file is created. So, all add() operations must be done with Mailbox owner UID/GID.
Trash folder is not counted within the quota.
Library just manage the size cache, it does not supperss nor add message by itself.
(Laurent Wacrenier) lwa@teaser.fr
mdq(3), maildirquota(7)
To install Maildir::Quota, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Maildir::Quota
CPAN shell
perl -MCPAN -e shell install Maildir::Quota
For more information on module installation, please visit the detailed CPAN module installation guide.