Virtual Users And Domains With Postfix, Courier And MySQL (Ubuntu 7.10) - Page 5

11 Quota Exceedance Notifications

If you want to get notifications about all the email accounts that are over quota, then do this:

cd /usr/local/sbin/
wget http://puuhis.net/vhcs/quota.txt
mv quota.txt quota_notify
chmod 755 quota_notify

Open /usr/local/sbin/quota_notify and edit the variables at the top. Further down in the file (towards the end) there are two lines where you should add a % sign:

vi /usr/local/sbin/quota_notify

[...]
my $POSTFIX_CF = "/etc/postfix/main.cf";
my $MAILPROG = "/usr/sbin/sendmail -t";
my $WARNPERCENT = 80;
my @POSTMASTERS = ('postmaster@yourdomain.tld');
my $CONAME = 'My Company';
my $COADDR = 'postmaster@yourdomain.tld';
my $SUADDR = 'postmaster@yourdomain.tld';
my $MAIL_REPORT = 1;
my $MAIL_WARNING = 1;
[...]
           print "Subject: WARNING: Your mailbox is $lusers{$luser}% full.\n";
[...]
           print "Your mailbox: $luser is $lusers{$luser}% full.\n\n";
[...]

Run

crontab -e

to create a cron job for that script:

0 0 * * * /usr/local/sbin/quota_notify &> /dev/null

 

12 Test Postfix

To see if Postfix is ready for SMTP-AUTH and TLS, run

telnet localhost 25

After you have established the connection to your Postfix mail server type

ehlo localhost

If you see the lines

250-STARTTLS

and

250-AUTH LOGIN PLAIN

everything is fine:

root@server1:~# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain.
Escape character is '^]'.
220 server1.example.com ESMTP Postfix (Ubuntu)
ehlo localhost
250-server1.example.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit
221 2.0.0 Bye
Connection closed by foreign host.
root@server1:~#

Type

quit

to return to the system shell.

Share this page:

5 Comment(s)

Add comment

Comments

From: Miquel at: 2008-12-17 10:33:26

You should correct it if you wish that your email quotas work properly.

In Postfix main.cf configuration file you should replace

virtual_mailbox_extended=yes

 for

virtual_maildir_extended=yes

If you don't do it, maildirsize files won't be created and Courier-Imap won't be able to check email quotas.

Thanks for this great HowTo!

 

 

 

From: at: 2008-03-18 15:48:16

If you include your hostname in the domains table, you should use this as the first postconf setting above for mydestination:

postconf -e 'mydestination = localhost, localhost.localdomain'

In other words, if your server1.example.com is mydomain.com, do not include mydomain.com in that list for mydestination if it is in the domains table, otherwise /var/log/mail.warn will give you lines like this, and email to mydomain.com will get bounced:

warning: do not list domain mydomain.com in BOTH mydestination and virtual_mailbox_domains

Otherwise, I followed this tutorial line-by-line and it works perfectly on Ubuntu 7.10 - nice work! 

From: at: 2008-01-26 16:55:33

Hi,

Great Howto, thank you very much for your work.

Just a comment: you don't need to set sql parameters and mysql as auxprop_plugin in /etc/postfix/sasl/smtpd.conf as you intend to use PAM for authentication.

The following /etc/postfix/sasl/smtpd.conf should suffice:

pwcheck_method: saslauthd
mech_list: plain login
allow_plaintext: true

This way, plain PAM will be used, with the options you set in /etc/pam.d/smtpd. Indeed, you don't even need to install libsasl2-modules-sql package (but you still do need libpam-mysql, of course).

Best regards,

Alberto Caso
Adaptia

From: at: 2008-05-01 06:58:34

on my 7.10 box i need to use 0 0 * * * root /usr/local/sbin/quota_notify &> /dev/null (note the username) or cron fails, HTH D

From: at: 2008-05-22 12:43:54

After spending quite a few hours debugging what a friend had done when following your excellent tutorial, I had a problem with loopbacks:

[QUOTE]May 22 12:34:34 odin postfix/smtp[8486]: 7499E215021A: to=<davie@*****.***>, relay=none, delay=0.06, delays=0.05/0.01/0/0, dsn=5.4.6, status=bounced (mail for localhost loops back to myself)[/QUOTE]


The problem was a result of him adding an entry in the transport table that resolved to the local machine:

[QUOTE]INSERT INTO `transport` (`domain`, `transport`) VALUES ('example.com', 'smtp:mail.example.com');[/QUOTE]

It might be worthwhile inserting a little note around this point to stop other people having the problem.

Thanks again for the tutorial.

-Colin