PDA

View Full Version : No Quota information in the mail


Tr!n!Ty
9th August 2007, 11:02
Hello,

I have a problem with the mail for the quota When i received mail there's no information in

DAILY QUOTA REPORT:

----------------------------------------------
| % UTILISATION | NOM DU COMPTE |
----------------------------------------------

--

I look in the post in the forum and modifie this line in /usr/local/sbin/quota_notify

close(QF);
next if (! $used);
my $percent = int($used / $quota * 100);
$lusers{$user} = $percent;

Added that too :

# Added to show if the path to the mailboxes are correct.
# At this point, its showing all the correct path to each mailbox
printf($mboxBase."/".$domain."/".$name."\n");

My main.cf

# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
myhostname = xxxxxxx
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

# TLS parameters
smtpd_tls_cert_file = /etc/postfix/smtpd.cert
smtpd_tls_key_file = /etc/postfix/smtpd.key
smtpd_use_tls = yes
smtpd_tls_session_cache_database = btree:${queue_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${queue_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases

#mydestination = localhost.$mydomain
mydestination = mail.xxxxxxx.org, mail.xxxxx.org, localhost, localhost.localdomain
mynetworks = 127.0.0.0/8
mailbox_size_limit = 51200000
maximal_queue_lifetime = 62d
debug_peer_level = 4
maildrop_destination_recipient_limit = 1

################################################## ##########
# UTILISATION MYSQL
################################################## ##########
virtual_mailbox_base = /home/vmail
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
virtual_transport = virtual
virtual_mailbox_extended = yes

virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual_domains.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailboxes.cf
virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual_forwardings.cf, mysql:/etc/postfix/mysql-virtual_email2email.cf


inet_protocols = ipv4
virtual_alias_domains =
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
transport_maps = proxy:mysql:/etc/postfix/mysql-virtual_transports.cf
virtual_create_maildirsize = yes
virtual_mailbox_limit_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = "The user you are trying to reach is over quota."
virtual_overquota_bounce = yes
proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps
content_filter = amavis:[127.0.0.1]:10024
receive_override_options = no_address_mappings

and my mysql-virtual_mailbox_limit_maps.cf

user = mail_admin
password = password
dbname = mail
query = SELECT quota FROM users WHERE email = '%s'
hosts = 127.0.0.1

When i do "sudo /usr/local/sbin/quota_notify"

I look the mysql.log and i don't see requet for the quotas

Anyone have idear ?

Thanks for help :)

there is juste quotas who don't work :(

falko
10th August 2007, 17:31
Did you modify the quota_notify script as shown on http://www.howtoforge.com/virtual_users_and_domains_with_postfix_debian_etch _p5 ?

Tr!n!Ty
12th August 2007, 12:12
Hello Falko,

I change the line but same issue i post my quota_notify

my $POSTFIX_CF = "/etc/postfix/main.cf";
my $MAILPROG = "/usr/sbin/sendmail -t";
my $WARNPERCENT = 80;
my @POSTMASTERS = ('postmaster@xxxxx.org');
my $CONAME = 'Server xxxxx';
my $COADDR = 'postmaster@xxxxx.org';
my $SUADDR = 'postmaster@xxxxx.org';
my $MAIL_REPORT = 1;
my $MAIL_WARNING = 1;

#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, {"$name\@$domain" => "$mboxBase/$domain/$name"});

# Added to show if the path to the mailboxes are correct.
# At this point, its showing all the correct path to each mailbox
printf($mboxBase."/".$domain."/".$name."\n");

}
}
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;
}
}

#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 "| % UTILISATION | NOM DU COMPTE |\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 monthly storage quota\n";
print "your monthly billing will be automatically adjusted.\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);
}
}

But why in the log on mysql, i don't see request for quota ?

falko
13th August 2007, 20:09
Which distribution are you using?

Tr!n!Ty
14th August 2007, 08:58
I'm using Ubuntu edgy

falko
15th August 2007, 19:28
Please try this:
ln -sf /bin/bash /bin/sh

sremac
14th September 2007, 17:16
Please try this:
ln -sf /bin/bash /bin/sh


hello,

have you noticed if somebody resolved problem with quota with
'home/vmail/domains'

because in /usr/local/sbin/quota_notify it suppose that you have in configuration

/home/vmail/domains/example.com/blabla

but real situation is just

/home/vmail/example.com/blabla

?

because of that, quota_notify can`t work well :confused:

Tr!n!Ty
14th September 2007, 23:54
i back home and this command change nothing the report quota is empty :(

justiceiro_df
26th September 2007, 23:07
hello,

have you noticed if somebody resolved problem with quota with
'home/vmail/domains'

because in /usr/local/sbin/quota_notify it suppose that you have in configuration

/home/vmail/domains/example.com/blabla

but real situation is just

/home/vmail/example.com/blabla

?

because of that, quota_notify can`t work well :confused:


I've notice that to, I have the same problem as descrive above... some one found any issue ???

:(

Pinki
18th January 2008, 00:18
Hello
change line 95
from: my $percent = int($used / $quota * 100);
to: my $percent = sprintf "%.3f",($used / $quota * 100);

and line 111
from: printf("| %3d | %32s |\n", $lusers{$luser}, $luser);
to: printf("| %.3f | %32s |\n", $lusers{$luser}, $luser);

--
Pinki
Lukasz Rostalski

thecaoticone
21st January 2008, 02:26
I've had the same problem.

Try this:
change your /etc/postfix/main.cf

change:
virtual_mailbox_extended = yes

to:
virtual_maildir_extended = yes

then reload postfix.

For a fresh install, send a test e-mail to your account. ( I used an attachment that was more than 1% of my quota. )

then login to the server as root and do:
/usr/local/sbin/quota_notify


You should now have an e-mail listing all users at 1% or more and the percentage of the quota used.