Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Installation/Configuration

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #11  
Old 14th July 2010, 17:48
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,751 Times in 2,581 Posts
Default

Did you modify the script as shown in the tutorial?
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
Sponsored Links
  #12  
Old 19th July 2010, 11:32
vigremrajesh vigremrajesh is offline
Junior Member
 
Join Date: Jul 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default mail quota alert postfix

No I didn't modify the script that is given..


The Highlighted alone I changed as I followed thread. other than that I didn't change anything.

#!/usr/bin/perl -w
2
3 use strict;
4
5 my $POSTFIX_CF = "/etc/postfix/main.cf";
6 my $MAILPROG = "/usr/sbin/sendmail -t";
7 my $WARNPERCENT = 1;
8 my @POSTMASTERS = 'pmghelpdesk@premediaglobal.com';
9 my $CONAME = 'PMG Helpdesk';
10 my $COADDR = 'pmghelpdesk@premediaglobal.com';
11 my $SUADDR = 'pmghelpdesk@premediaglobal.com';
12 my $MAIL_REPORT = 1;
13 my $MAIL_WARNING = 1;
14
15 #get virtual mailbox base from postfix config
16 open(PCF, "< $POSTFIX_CF") or die $!;
17 my $mboxBase;
18
19 while (<PCF>) {
20 next unless /virtual_mailbox_base\s*=\s*(.*)\s*/;
21 $mboxBase = $1;
22 }
23 close(PCF);
24
25 #assume one level of subdirectories for domain names
26 my @domains;
27 opendir(DIR, $mboxBase) or die $!;
28 while (defined(my $name = readdir(DIR))) {
29 next if $name =~ /^\.\.?$/; #skip '.' and '..'
30 next unless (-d "$mboxBase/$name");
31 push(@domains, $name);
32 }
33 closedir(DIR);
34
35 #iterate through domains for username/maildirsize files
36 my @users;
37 chdir($mboxBase);
38 foreach my $domain (@domains) {
39 opendir(DIR, $domain) or die $!;
40 while (defined(my $name = readdir(DIR))) {
41 next if $name =~ /^\.\.?$/; #skip '.' and '..'
42 next unless (-d "$domain/$name");
43
44 push(@users, {"$name\@$domain" => "$mboxBase/$domain/$name"});
45
46
47 # Added to show if the path to the mailboxes are correct.
48 # At this point, its showing all the correct path to each mailbox
49 printf($mboxBase."/".$domain."/".$name."\n");
50
51
52 }
53 }
54 closedir(DIR);
55
56 #get user quotas and percent used
57 my (%lusers, $report);
58 foreach my $href (@users) {
59 foreach my $user (keys %$href) {
60 my $quotafile = "$href->{$user}/maildirsize";
61 next unless (-f $quotafile);
62 open(QF, "< $quotafile") or die $!;
63 my ($firstln, $quota, $used);
64 while (<QF>) {
65 my $line = $_;
66 if (! $firstln) {
67 $firstln = 1;
68 die "Error: corrupt quotafile $quotafile"
69 unless ($line =~ /^(\d+)S/);
70 $quota = $1;
71 last if (! $quota);
72 next;
73 }
74 die "Error: corrupt quotafile $quotafile"
75 unless ($line =~ /\s*(-?\d+)/);
76 $used += $1;
77 }
78 close(QF);
79 next if (! $used);
80 my $percent = int($used / $quota * 100);
81 # $lusers{$user} = $percent unless not $percent;
82 $lusers{$user} = $percent;
83 }
84 }
85
86 #send a report to the postmasters
87 if ($MAIL_REPORT) {
88 open(MAIL, "| $MAILPROG");
89 select(MAIL);
90 map {print "To: $_\n"} @POSTMASTERS;
91 print "From: $COADDR\n";
92 print "Subject: Daily Quota Report.\n";
93 print "DAILY QUOTA REPORT:\n\n";
94 print "----------------------------------------------\n";
95 print "| % USAGE | ACCOUNT NAME |\n";
96 print "----------------------------------------------\n";
97 foreach my $luser ( sort { $lusers{$b} <=> $lusers{$a} } keys %lusers ) {
98 print ("| %3d | %32s |\n", $lusers{$luser}, $luser);
99 print "---------------------------------------------\n";
100 }
101 print "\n--\n";
102 print "$CONAME\n";
103 close(MAIL);
104 }
105
106 #email a warning to people over quota
107 if ($MAIL_WARNING) {
108 foreach my $luser (keys (%lusers)) {
109 next unless $lusers{$luser} >= $WARNPERCENT; # skip those under quota
110 open(MAIL, "| $MAILPROG");
111 select(MAIL);
112 print "To: $luser\n";
113 map {print "BCC: $_\n"} @POSTMASTERS;
114 print "From: $SUADDR\n";
115 print "Subject: WARNING: Your mailbox is $lusers{$luser} full.\n";
116 print "Reply-to: $SUADDR\n";
117 print "Your mailbox: $luser is $lusers{$luser} full.\n\n";
118 print "Once your e-mail box has exceeded your monthly storage quota\n";
119 print "your monthly billing will be automatically adjusted.\n";
120 print "Please consider deleting e-mail and emptying your trash folder to clear some space.\n\n";
121 print "Contact <$SUADDR> for further assistance.\n\n";
122 print "Thank You.\n\n";
123 print "--\n";
124 print "$CONAME\n";
125 close(MAIL);
126 }
127 }
Reply With Quote
  #13  
Old 20th July 2010, 14:55
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,751 Times in 2,581 Posts
Default

Which tutorial (URL) did you use?
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #14  
Old 22nd July 2010, 14:19
vigremrajesh vigremrajesh is offline
Junior Member
 
Join Date: Jul 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb mail quota alert postfix

I don't know what you are asking? But I didn't refer any tutorial for the above script. I have just copied the script from the same thread and try to execute. So when I got the error, I again while going through the same thread I noticed there is small change in that script & I did that....even though I got the output as I mentioned earlier.........


thanks & regards
vigrem rajesh
Reply With Quote
  #15  
Old 23rd July 2010, 14:35
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,751 Times in 2,581 Posts
 
Default

So you didn't use any of the "Virtual Users And Domains With Postfix, Courier And MySQL" tutorials here on HowtoForge?
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Postfix Email Delivery Problem sedat1903 HOWTO-Related Questions 2 22nd December 2008 12:19
postfix email problem Andee63 Installation/Configuration 10 27th March 2007 18:09
Centos 4.4 32bit Hangs, High Server load 3cwired_com Server Operation 11 16th November 2006 16:47
Verify email setup meekish Installation/Configuration 28 27th October 2006 16:36
Problem in setting quota in postfix Talat Server Operation 1 22nd May 2006 09:48


All times are GMT +2. The time now is 04:42.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.