On 12/3/00 11:20 PM, "unplug" <[EMAIL PROTECTED]> wrote:

> But I would like to know the situation below.
> The qutoa of user.abc is 10000.
> I send several mail to user.abc that make his account to 11000.

If a certain user is below 100% of their quota *any* email that's being
received will be delivered. It will not be rejected because of quota until
they are *over* their quota.

Example:

User.abc has a 10MB quota.
User is at 8MB of mail stored - 80% full.
User is receiving a 10MB email - since they are still below 99% full, cyrus
will take and store the email.
Now they're at 180% and no more mail will be received.

> I continue to send mail to user.abc but he can't receieve it anymore.
> Q: How can I make a warning message to the sender & receiver to tell
> them 
> there is a qutoa problem??

I posted a script that does this already - I run it from cron every night:

#!/usr/bin/perl

# TODO
# 1. Make this web enabled for checking by the individual users.
# 2. Make it configurable % wise for each user with 80% as the default.

# Perl Module
use Mail::Mailer;

# Variables
$quota_warn = "80";
$quota_max = "99";
$quota_application = "/usr/local/cyrus-imapd/bin/quota|";
$sysadmin_email = "sysadmin\@domain.com";
$email_subject = "It's time to clean out your email!";

$email_body_standard = "In order to assure that you will not lose any email
(due to being over your email storage quota), ";
$email_body_standard .= "please clean up and delete any email that is not
needed  anymore. Messages with large attachments (sounds, movies, etc.) are
the usual culprits, taking up large amounts of space and storage
capacity.\n\n";
$email_body_standard .= "You will continue to receive this email once a day
until your email usage goes below $quota_warn%.\n\n";
$email_body_standard .= "If you have any questions at all, please don't
hesitate to contact $sysadmin_email for any further clarification.\n\nThe
Server Team";

# TODO: Check to see if you're the cyrus user.

# This is the motherlode of cyrus quota information.
open (QUOTA, "$quota_application");

# Go!
while (<QUOTA>) {
    chomp;
    ($null, $quota, $percent, $used, $user) = split(/\s+/);
    ($null, $user) = split(/\./, $user);

    # Log the info to /var/log/messages if they're over 80% full.
    system ("/usr/bin/logger \"$user is at $percent\% of mail quota.\"") if
($percent > $quota_warn);

    # Send the user an explanatory email if they're over $quota_warn (but
under $quota_max) full.
    if (($percent > $quota_warn) && ($percent < $quota_max)) {

        # Create the email body.
        $email_body = "This is just a friendly reminder that your email that
is stored on the server is $percent\% full.\n\n";
        $email_body .= $email_body_standard;
        
        $mailer = Mail::Mailer->new();
        $mailer->open({    From    =>    $sysadmin_email,
                To    =>    $user,
                Subject =>    $email_subject,
            }) or die;
    print $mailer $email_body;
    $mailer->close();
    } else {
        # Do nothing.
    }

    # If the user is over $quota_max, any mail for them will bounce SO
    # send a quick email to sysadmin to let them know.
    if ($percent > $quota_max) {
        $warning_body = "$user is at $percent\% of mail quota.";
        $warning_subject = "$user is over quota and is now bouncing email";
                $mailer = Mail::Mailer->new();
                $mailer->open({ From    =>      $sysadmin_email,
                                To      =>      $sysadmin_email,
                                Subject =>      $warning_subject,
                        }) or die;
    print $mailer $warning_body;
    $mailer->close();
    }
}

It's pretty rough but it works. It looks through the quota each night and:

1. Notifies the user if they're over $quota_min full and below $quota_max.

2. If they're over $quota_max - then the sysadmin is notified so that they
can deal with it.

> However, I can see the maillog and the mail still sending to user.abc.
> Q: I wonder where is the mail store.

The mail store is setup in the /etc/imapd.conf in the "partition-default"
setting.

> Q: Can user.abc get back the mails after deleting the existing mail,
> how??

If it's deleted - it's gone. I'm a little confuzed as to what you're asking
here.
-- 
Darron
[EMAIL PROTECTED]

Reply via email to