This is awesome, I'd like to include it in the distribution as a contrib script.
Rather than using sendmail, 'dbmail-smtp -M Inbox -u username' will deliver the message directly without running sieves or checking quotas. I'll hack on it a bit this week. As for the thread, there's a lot more little site policy decisions involved than I thought at first blush. I'd be much more comfortable with an external script that can be readily adapted to each site. Aaron On Wed, Nov 21, 2007, Simon Lange <[EMAIL PROTECTED]> said: > I have written a small perl script which checks quota AND sends warning > mails. You may want to use it. Its under GPL of course. ;) > > It uses the dbmail-util. its quick its dirty but it works like a charme for > years meanwhile. ;) > > Here it is: > > <snip> > #!/usr/bin/perl > > ## Please set the correct path of dbmail-utilities > $dbmailutil = "/usr/sbin/dbmail-util"; > $dbmailusers = "/usr/sbin/dbmail-users"; > > ## path of your sendmail binary > $sendmail = "/usr/sbin/sendmail -t"; > > ## amount of percentage when warning mails are sent > $quotawarn = 90; > > ## Mail Content > $from = "[EMAIL PROTECTED]"; > $bcc = $from; > $mail = "Dear %USER%,\n". > "You have crossed the $quotawarn% Limit of your > MailAccount-Quota.\n". > "Please DO DELETE some mails, empty your trash or > doing anything for\n". > "falling under $quotawarn% usage of you quota.\n\n". > "BE WARNED! If your mailaccount runs full, all MAILS > regardless what\n". > "content or what age they may have will be > DELETED!\n\n". > "Currently you have used %USED%% or your > quota.\n\n". > "All the best\n\n". > "Postmaster System\n"; > > $mail2 = "Dear %USER%,\n". > "Although we have warned you, you did nothing to > prevent your mailaccount.\n". > "from running full. As warned several times we have > now deleted ALL your\n". > "mails from the server, so people can send you mails > again.\n\n". > "Currently you have used %USED%% or your > quota.\n\n". > "All the best\n\n". > "Postmaster System\n"; > > > ## !!!do not change anything below!!! ## > $getusers = "$dbmailusers -l |egrep '\\[(.*)\\]'"; > $getuserinfo1 = "$dbmailusers -l"; > $getuserinfo2 = "|grep Quotum|gawk -F '(' '{print \$2}'"; > $getuserinfo3 = "|grep \@"; > > @users=`$getusers`; > $r=`$dbmailutil -d -qq`; > $r=`$dbmailutil -p -qq`; > > foreach $user(@users){ > $user=~s/\[//gi;$user=~s/\]//gi;$user=~s/\n//gi; > $quota=`$getuserinfo1 $user $getuserinfo2`; > $quota=~s/\%//gi;$quota=~s/\)//gi;$quota=~s/\n//gi; > if($user=~/^__/i){ > }else{ > if($quota >= $quotawarn && $quota != 100){ > @email=`$getuserinfo1 $user $getuserinfo3`; > $email[0]=~s/\n//gi; > open (SENDMAIL, "|$sendmail") or die "Could not open $sendmail: > $!\n"; > print SENDMAIL "Reply-to: $from\n"; > print SENDMAIL "Subject: Quotawarning for Account $user\n"; > print SENDMAIL "To: $email[0]\n"; > print SENDMAIL "Content-type: text/plain\n\n"; > $mail=~s/%USER%/$user/g; > $mail=~s/%USED%/$quota/g; > print $mail; > close(SENDMAIL); > } > if($quota == 100){ > @email=`$getuserinfo1 $user $getuserinfo3`; > $email[0]=~s/\n//gi; > $result=`$dbmailusers -e $user`; > $r=`$dbmailutil -d -qq`; > $r=`$dbmailutil -p -qq`; > open (SENDMAIL, "|$sendmail") or die "Could not open $sendmail: > $!\n"; > print SENDMAIL "Reply-to: $from\n"; > print SENDMAIL "Subject: Emails erased for Account $user\n"; > print SENDMAIL "To: $email[0]\n"; > print SENDMAIL "Bcc: $bcc\n"; > print SENDMAIL "Content-type: text/plain\n\n"; > $mail2=~s/%USER%/$user/g; > $mail2=~s/%USED%/$quota/g; > print $mail2; > close(SENDMAIL); > } > } > } > <snap> > > You may want to download it since I don�t know how the mailinglist will > treat this mail. ;) > http://www.simonlange.de/dbmail-quotacheck.tgz > > best regards > > Simon > > -----Urspr�ngliche Nachricht----- > Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag > von Aaron Stone > Gesendet: Mittwoch, 21. November 2007 08:07 > An: DBMail mailinglist > Betreff: Re: [Dbmail] Mailbox full + sieve > > It's not possible with Sieve right now, but could be done with the > environment extension that's been talked about on the Sieve mailing > list. Anyway, that's sort of pie-in-the-sky at this moment. > > We don't currently put an alert email into a user's mailbox when they've > reached quota, but we certainly could do that. There'd have to be an > effective way to prevent the message from being delivered more than once > in a given timeframe -- the replycache table could do the trick for > storing that information. There's also no way to insert the message > without counting it towards the quota (well, it's _possible_ but would > involve hacking across abstraction layers). > > How about this config item: > > [DELIVERY] > quota_warnings = yes/no > > How do other mail systems do this? Is there a general desire for a > feature like this? > > Aaron > > > On Wed, 2007-11-21 at 06:48 +0000, James Greig wrote: >> Hi guys, >> >> This may have already been mentioned before. Is there a feature in >> dbmail that can place an email into a users mailbox alerting them when >> their mailbox quota is reaching its limit, say at 95% usage or >> something? If not, is this achieveable using sieve perhaps? >> >> Cheers in advance >> >> James Greig >> >> >> _______________________________________________ >> DBmail mailing list >> DBmail@dbmail.org >> https://mailman.fastxs.nl/mailman/listinfo/dbmail > > _______________________________________________ > DBmail mailing list > DBmail@dbmail.org > https://mailman.fastxs.nl/mailman/listinfo/dbmail > > _______________________________________________ > DBmail mailing list > DBmail@dbmail.org > https://mailman.fastxs.nl/mailman/listinfo/dbmail > -- _______________________________________________ DBmail mailing list DBmail@dbmail.org https://mailman.fastxs.nl/mailman/listinfo/dbmail