Today we will be talking about how to configure user and domain quotas with dovecot 2 on virtual users mail service.
At this time we are assuming you have a fully running mail server and you just want to implement domain and mailbox quotas to control individual users storage limit.

This tutorial will use the following softwares to reach the goal:-

Dovecot 2.2   for handling the quota measures on the users mailboxes
PostfixAdmin for setting the mailbox and domain quota limits

The text highlgted in red are the files you need to edit, and the text highlited in green are the changes you need to add on the edited files

First of all, we will edit some settings on postfixadmin config file to enable the quota table on editing domain and mailboxes

Edit the file with your favorite editor  /etc/postfixadmin/config.inc.php look for the lines below and edit them accordingly

After finished editing the three lines, save the changes and restart web server for the changes to take effect

You can try to browse postfixadmin and login to see if the changes are available on adding domain or mailbox interface

Now lets move to Dovecot and do the really quota job that will handle the mailbox size and give notifications incase the mailbox is full or amost
We will create two files that will handle users and domain quotas
You can use the command below  to create  and add the content below in the file

# vim /etc/dovecot/dovecot-dict-sql-user.conf 

# vim /etc/dovecot/dovecot-dict-sql-domain.conf

Edit the below files to make some changes

# vim /etc/dovecot/conf.d/auth-sql.conf.ext

# vim /etc/dovecot/conf.d/10-master.cf

# vim /etc/dovecot/conf.d/10-mail.conf

# vim /etc/dovecot/conf.d/20-imap.conf

You can also edit /etc/dovecot/conf.d/20-pop3.conf and set mail_plugins = $mail_plugins pop3_quota if you use pop for your customers, but its not really necessary for now

Now Edit  vim /etc/dovecot/conf.d/90-quota.conf and add the following lines at the end

Now as we are approaching the end of this tutorial, lets edit the file that connects to the MySQL Database to check the users and passwords for authentications.
We will modify the queries to check user and domain quotas set before a mail can be delivered

Save the file and restart dovecot service for the changes to take effect
# /etc/init.d/dovecot restart

For now that’s all what we need for the creation and editing of files on postfixadmin and dovecot, Try to login if your using RoundCube webmail and check at the bottom left, it will show you the percentage of your mailbox