Procmail with Virtual Quotas
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.
- Roundcube is unable to correctly display disk usage,
- This Postfix quota notification script does not work correctly, sending a blank email once a day
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.