#!/usr/bin/perl use strict; use warnings; use POSIX qw/strftime/; ## Many thanks to Simon Lange for posting the original version of ## this script to the dbmail mailing list and giving permission to ## make it part of DBMail . I've modified it to be a little more ## general-purpose than Simon's original script, but all the good ## ideas here are his. ## - Aaron Stone, December 2007 ## Please set the correct path of dbmail-utilities my $dbmailusers = "/usr/local/sbin/dbmail-users"; ## We'll use the -M option to force delivery without ## consideration of quotas or sieve scripts. my $delivery = "/usr/local/sbin/dbmail-smtp"; ## Quota percentage when warning mails are sent my $warnpercent = 90; ## Mail Content my $from = "postmaster"; my $date = strftime("%a, %d %b %Y %H:%M:%S %z", localtime); my $msg = sub { return < 0.00; my $percent = $used / $quota * 100; next if $percent < $warnpercent; open (SMTP, "|$delivery -M Inbox -u $username") or die "Could not open $delivery: $!\n"; print SMTP $msg->($username, sprintf("%.1f", $percent), $warnpercent); close(SMTP); $count++; } print "Sent $count warnings out of $total users.\n";