Postfix does not support mailbox quota. But thanks to Anderson Nadal’s Postfix Virtual Delivery Agent (VDA) patches, it can. To use the Postfix VDA requires two things, first Postfix must be built with the VDA patches and second, virtual user accounts must be used. You can get the Postfix RPM with VDA patches here.
If you have installed Postfix with VDA and your Postfix is configured for virtual user accounts, you can proceed to Configure Postfix VDA section.
Create the Virtual Mail User Account

1. Create a new user, we will call it vmail. Change the Login Shell to /sbin/nologin, this user account should not be used for logging in. Learn how to use the User Manager application here.
3. Click the Groups tab and now note down the Group ID of vmail. We’ll be needing all of them later.Configure Postfix for Virtual User Accounts
mydestination = $myhostname, localhost.$mydomain, localhost
and add the lines below
virtual_mailbox_domains = $mydomain virtual_mailbox_base = /home/vmail/ virtual_mailbox_maps = hash:/etc/postfix/vmailbox virtual_uid_maps = static:501 virtual_gid_maps = static:501
virtual_mailbox_base, virtual_uid_maps and virtual_gid_maps should contain the home directory, user id and group id of vmail respectively.

2. Create the file /etc/postfix/vmailbox containing the mapping from an email address to a mailbox path relative to virtual_mailbox_base. See the example below.
johndoe@acme.local johndoe/Maildir/ janedoe@acme.local janedoe/Maildir/
You can generate the vmailbox file automatically by executing
getent passwd | grep /bin/bash | sed 's/\([^:]*\):.*/\1@acme.local \1\/Maildir\//' > /etc/postfix/vmailbox
After creating this file, execute postmap /etc/postfix/vmailbox. This will generate /etc/postfix/vmailbox.db, the actual file that will be used for the lookup.

3. Restart the Postfix or MailScanner service if you have installed MailScanner. Learn how to start and stop services here.
4. Try sending an email. See Test Postfix using Telnet. New mails should now be stored under the path specified in virtual_mailbox_base.Configure Dovecot Virtual User Accounts

1. Edit the file /etc/dovecot.conf and change the value of the following keys below
userdb static {
args = uid=501 gid=501 home=/home/vmail/%u
}
uid, gid and home should contain the user id, group id and home directory respectively of the vmail user account.
You should also comment out the userdb passwd section, otherwise it will override the values in userdb static above.

2. Restart the dovecot service. Learn how to start and stop services here.
3. Test Dovecot using Telnet. You should be able to read the recently sent mail which was stored in a new location.Configure Postfix VDA

1. Edit the postfix configuration file /etc/postfix/main.cf and add the lines below
virtual_mailbox_limit_override = yes virtual_mailbox_limit_maps = hash:/etc/postfix/vquota

2. Create the file /etc/postfix/vquota containing the mapping from an email address to the maximum mailbox quota in bytes. If you wish to be exact, 1KB equals 1024 bytes while 1MB equals 1024KB or 1048576 bytes.
johndoe@acme.local 10485760 janedoe@acme.local 2097152
John Doe got a 10MB quota while Jane Doe got 2MB.
After creating this file, execute postmap /etc/postfix/vquota. This will generate /etc/postfix/vquota.db, the actual file that will be used for the lookup.
If you use Active Directory as your Postfix virtual user accounts source, you can use the maxStorage attribute instead to store the quota. Just copy your ldap-users.cf configuration and save it as ldap-quota.cf. Next change samaccountname to maxstorage in the result_attribute line and remove the result_format line. In your main.cf, use ldap:/etc/postfix/ldap-quota.cf as your virtual_mailbox_limit_maps. In Windows, you can use ADSI Edit to access and modify the value of maxStorage.

3. Restart the Postfix or MailScanner service if you have installed MailScanner. Learn how to start and stop services here.
4. Test Postfix using Telnet. Try using a very small quota limit so you can test the quota feature.***
Posted on 4/20/2008 and last updated on 4/20/2008
Filed under Postfix
Share This


April 27th, 2008 at 12:08 pm
Hi,
How do I know if my postfix version installed has the VDA patch? Will using your postfix version(the one patched already) be as easy as upgrading the built-in postfix of CentOS 5?
April 27th, 2008 at 12:28 pm
Hi,
A question on this line:
In your main.cf, use ldap:/etc/postfix/ldap-quota.cf as your virtual_mailbox_limit_maps.
Does this mean that I will replace virtual_mailbox_maps with the line above or just add the line above in the bottom?
April 28th, 2008 at 12:23 am
I don’t know of any command to check for the presence of VDA and installing the patched one is as easy as upgrading the built-in Postfix.
April 28th, 2008 at 12:24 am
Yes correct, you will replace virtual_mailbox_maps with the ldap version.
July 31st, 2008 at 11:48 am
hey dude, just to clarify things to avoid misconception, “Postfix does not support mailbox quota.”. There are two types of how an MTA saves our mail, 1 is the traditional unix “mailbox” which saves all of your emails on a single file, on most cases (depending or your distro) it is stored at /var/spool/mail. The other one is Maildir/ which is more efficient way of storing mails. VDA patch only works with Maildir/ formats so as its quota features, i think that is should be “Mail Quota” instead of “mailbox quota” cause that would confuse some of the people who reads it and led them to thinking that your pertaining to the traditional “mailbox” method of storing mails..
cheers.. keep it up.
August 8th, 2008 at 3:09 pm
Hi netbeui,
The Postfix Quota patch works with both Mailbox and Maildir format. The only requirement is to use virtual accounts.
From the website:
Mailbox / Maildir size limit, known also as “soft quota”, to avoid user take all you disk space
I’ve also tried it myself and it works.