by Daniel Davies

I recently discovered that if you are using a patched Postfix server to provide mail quotas with virtual users, but also want to have mail delivered locally by procmail then you lost quota functionality. This leads to a number of problems.

I discovered that the problem lay with a file called maildirsize, which Postfix's VDA apparently creates upon delivery of mail. By delivering via procmail the VDA is by-passed and Procmail will not create this file for you. After a lot of Googling I was unable to find a satisfactory resolution to this problem, so I wrote a quick script which you can run to rebuild this file.

If you're using virtual mailboxes you no doubt have a scipt sat between Postfix and Procmail which seperates the user and the domain, something like this:

#!/bin/sh
DOMAIN=$(echo $1 | sed 's/.*@//g')
USER=$(echo $1 | sed 's/@.*//g')
/usr/bin/procmail -p -m /etc/procmailrc $DOMAIN $USER

Simply add a call at the end of this script to the rebuild file, and every time mail is delivered the maildirsize file will be recreated with the correct quota from the database.

#!/bin/sh
DOMAIN=$(echo $1 | sed 's/.*@//g')
USER=$(echo $1 | sed 's/@.*//g')
/usr/bin/procmail -p -m /etc/procmailrc $DOMAIN $USER
/mailtools/build_quotas.php $USER $DOMAIN

You'll need to copy the config-sample.php to config.php and fill in the correct values of course.

View the script in my subversion respository

Talk about Procmail with Virtual Quotas

No comments yet! Why not be the first?

Contact Daniel…

Request a Quote