hdismanto wrote:
hehehe ... siapa tau temen2x ada yang punya? mohon bantuannya.


quota notify seperti ini?

#!/usr/bin/perl -w

# Author <j...@tntmax.com>
#
# This script assumes that virtual_mailbox_base in defined
# in postfix's main.cf file. This directory is assumed to contain
# directories which themselves contain your virtual user's maildirs.
# For example:
#
# -----------/
#            |
#            |
#    home/vmail/domains/
#        |          |
#        |          |
#  example.com/  foo.com/
#                   |
#                   |
#           -----------------
#           |       |       |
#           |       |       |
#         user1/   user2/  user3/
#                           |
#                           |
#                        maildirsize
#

use strict;

my $POSTFIX_CF = "/etc/postfix/main.cf";
my $MAILPROG = "/usr/sbin/sendmail.postfix -t";
my $WARNPERCENT = 90;
my @POSTMASTERS = ('postmas...@domain.com');
my $CONAME = 'PT. BLABLA';
my $COADDR = 'postmas...@domain.com';
my $SUADDR = 'postmas...@domain.com';
my $MAIL_REPORT = 1;
my $MAIL_WARNING = 0;

#get virtual mailbox base from postfix config
open(PCF, "< $POSTFIX_CF") or die $!;
my $mboxBase;
while (<PCF>) {
  next unless /virtual_mailbox_base\s*=\s*(.*)\s*/;
  $mboxBase = $1;
}
close(PCF);

#assume one level of subdirectories for domain names
my @domains;
opendir(DIR, $mboxBase) or die $!;
while (defined(my $name = readdir(DIR))) {
  next if $name =~ /^\.\.?$/;        #skip '.' and '..'
  next unless (-d "$mboxBase/$name");
  push(@domains, $name);
}
closedir(DIR);
#iterate through domains for username/maildirsize files
my @users;
chdir($mboxBase);
foreach my $domain (@domains) {
       opendir(DIR, $domain) or die $!;
       while (defined(my $name = readdir(DIR))) {
          next if $name =~ /^\.\.?$/;        #skip '.' and '..'
          next unless (-d "$domain/$name");
     push(@users, {"$na...@$domain" => "$mboxBase/$domain/$name"});
       }
}
closedir(DIR);
#get user quotas and percent used
my (%lusers, $report);
foreach my $href (@users) {
  foreach my $user (keys %$href) {
     my $quotafile = "$href->{$user}/maildirsize";
     next unless (-f $quotafile);
     open(QF, "< $quotafile") or die $!;
     my ($firstln, $quota, $used);
     while (<QF>) {
        my $line = $_;
             if (! $firstln) {
                $firstln = 1;
die "Error: corrupt quotafile $quotafile" unless ($line =~ /^(\d+)S/);
                $quota = $1;
           last if (! $quota);
           next;
        }
        die "Error: corrupt quotafile $quotafile"
           unless ($line =~ /\s*(-?\d+)/);
        $used += $1;
     }
     close(QF);
     next if (! $used);
my $percent = int($used / $quota * 100); $lusers{$user} = $percent unless not $percent;
  }
}

#send a report to the postmasters
if ($MAIL_REPORT) {
open(MAIL, "| $MAILPROG"); select(MAIL);
  map {print "To: $_\n"} @POSTMASTERS;
  print "From: $COADDR\n";
  print "Subject: Daily Quota Report.\n";
  print "DAILY QUOTA REPORT:\n\n";
  print "----------------------------------------------\n";
  print "| % USAGE |            ACCOUNT NAME          |\n";
  print "----------------------------------------------\n";
  foreach my $luser ( sort { $lusers{$b} <=> $lusers{$a} } keys %lusers ) {
     printf("|   %3d   | %32s |\n", $lusers{$luser}, $luser);
     print "---------------------------------------------\n";
  }
       print "\n--\n";
       print "$CONAME\n";
       close(MAIL);
}

#email a warning to people over quota
if ($MAIL_WARNING) {
       foreach my $luser (keys (%lusers)) {
          next unless $lusers{$luser} >= $WARNPERCENT;       # skip those under 
quota
open(MAIL, "| $MAILPROG"); select(MAIL);
          print "To: $luser\n";
     map {print "BCC: $_\n"} @POSTMASTERS;
          print "From: $SUADDR\n";
          print "Subject: WARNING: Your mailbox is $lusers{$luser} full.\n";
          print "Reply-to: $SUADDR\n";
          print "Your mailbox: $luser is $lusers{$luser} full.\n\n";
          print "Once your e-mail box has exceeded your storage quota\n";
     print "your account will be automatically adjusted/disabled.\n";
     print "Please consider deleting e-mail and emptying your trash folder to clear 
some space.\n\n";
          print "Contact <$SUADDR> for further assistance.\n\n";
          print "Thank You.\n\n";
          print "--\n";
          print "$CONAME\n";
          close(MAIL);
       }
}







PT.CITRA SARI MAKMUR
SATELLITE & TERRESTRIAL NETWORK

Connecting the distance - anytime, anywhere, any content
http://www.csmcom.com


--
FAQ milis di http://wiki.linux.or.id/FAQ_milis_tanya-jawab
Unsubscribe: kirim email ke tanya-jawab-unsubscr...@linux.or.id
Arsip dan info milis selengkapnya di http://linux.or.id/milis

Kirim email ke