Posts tagged with shell script:

Maildirsize fix for Postfix 2.4.5 in Ubuntu 7.10 (Gutsy)

After installing Postfix in Ubuntu 7.10 with the help of this excellent howto (yes it looks very similar to mine, because mine is based on that one as well) I found that the maildirsize file wasn’t being created properly by Postfix. Unable to find the solution within Postfix I wrote this script. It basically builds a fake maildirsize file for all your users. If you have a really large server with many virtual accounts this may not be for you. However it works great for my needs.

First you will need to install the Mysql module for Perl. This can be done by running the following in a shell:

perl -MCPAN -e shell

If you’ve never used the cpan shell before you will need to go through the setup. I can’t really help with that (mostly defaults but you are on your own).

Once you get to a prompt type the following:

cpan> force install Bundle::Mysql

That should force it in (it will die if it can’t connect as root to your DB).

Then you need to put the script somewhere, so download it and get it on your server:

mv maildirfix /usr/local/sbin/<br />chown +x /usr/local/sbin/maildirfix

Change the DB info:

vi /usr/local/sbin/maildirfix

and edit the lines as approprate:

my $DBN = "mail";<br />my $DBU = "DBUSER";<br />my $DBP = "DBPASSWORD";<br />my $DBH = "localhost";

Now add it to your crontab:

crontab -e
0 23 * * * /usr/local/sbin/maildirfix

This will run it one hour before the quota_notify script is triggered if you followed the howto.

Maildirfix