#!/usr/bin/perl -w # # Quota check version 0.1 (alpha) # # By Charles Schweizer # # This program check user quota information and then # sends out e-mail to users over their quota. # open(QUOTA, "quota.txt") || die "can't open quota.txt: $!"; @users = ; $lenvar = 10; # Open Sendmail # # open (SENDMAIL, "|/usr/sbin/sendmail -t") or die "Can't open sendmail: $!"; print SENDMAIL <<"EOH"; To: ADMINISTRATOR'S EMAIL From: Mail Admin Subject: Oversized Mailboxes The following users have exceeded their limit for mailboxes: User : Mailbox Size in MB : Quota Size in MB ------------------------------------------------ EOH while($_ = ){ chomp $_ ; if ($_ =~ /\+/ ){ ($userid, $tmp1) = split(/\+/,$_); ($userid) = split(/\s+/,$userid); (undef, $used, $soft, undef, $grace) = split(/\s+/,$tmp1); $used = $used/1000; $soft = $soft/1000; foreach $user (@users) { $user =~ s#.*/##; $userlen = length($userid); if ($userlen >= $lenvar){ $userlen = length($user); if ($userlen >= $lenvar){ if($user =~ /^$userid/){ &mailuser($user, $soft, $used, $grace); print SENDMAIL "$user : $used MB : $soft MB \n"; } } } else { if($user eq $userid){ &mailuser($user, $soft, $used, $grace); print SENDMAIL "$user : $used MB : $soft MB \n"; } } } } } print SENDMAIL "\n\n.\n"; close(SENDMAIL); close(QUOTA); # Subroutines # # mailuser -- notifys user of mailbox exceeding limit # sub mailuser { open (SENDMAIL2, "|/usr/sbin/sendmail -t") or die "Can't open sendmail: $!"; ## Being non-standard spacing ## print SENDMAIL2 <<"EOM"; To: <$_[0]\@YOUR.ISP> From: YOUR SUPPORT Subject: Oversized Mailbox Dear Subscriber: Hi. This is an automated note to inform you that you have exceeded the $_[1] MB mail-storage limit. To assist us in providing quality service and consistent performance to our customers, please make sure you have the following mail options set: Netscape Users - Under the Options\Mail and News Preference: 1. Make sure that the "Remove From Server" option IS selected. Eudora Users - Under the Special/Settings/Checking Mail: 1. Make sure the "Leave On Server For" option is NOT selected. 2. Make sure the "Delete From Server When Emptied From Trash" IS selected. If you need to store your email for an extended period of time, ie. vacations etc. you MUST notify YOUR SUPPORT. Otherwise your mail box will be emptied $_[3] day(s) after this notification. If you have questions please email YOUR SUPPORT\@YOUR.ISP. You current mailbox size is: $_[2] MB Sincerely, YOUR ISP . EOM ## End non-standard spacing ## }