Configure quota mail user with postfix mysql dovecot

1- Configuring PostfixAdmin To Enable Quota Limits

Within the file /etc/postfixadmin/config.inc.php the following parameters need altering :

#vim /var/www/html/postfixadmin/config.inc.php
find and change like this:
$CONF['quota'] = 'YES';

$CONF['used_quota_table'] = 'YES';
$CONF['new_quota_table'] = 'YES';
2- Enabling Quota Mailbox Limits in Dovecot

Create file /etc/dovecot/dovecot-dict-sql-user.conf, and populate it with the following information ensure that you change "postfix_complex_password" to the MySQL mail access account that can select, update, delete the quota2 table:

#vim /etc/dovecot/dovecot-dict-sql-user.conf
connect = host=localhost dbname=postfix user=postfix password=postfix_complex_password

map {
  pattern = priv/quota/storage
  table = quota2
  username_field = username
  value_field = bytes
}
map {
  pattern = priv/quota/messages
  table = quota2
  username_field = username
  value_field = messages
}
Create /etc/dovecot/dovecot-dict-sql-domain.conf, again change"postfix_complex_password" to match the user account the postfix uses to adminster its tables as follows:

#vim /etc/dovecot/dovecot-dict-sql-domain.conf
connect = host=localhost dbname=postfix user=postfix password=postfix_complex_password

map {
    pattern = priv/quota/storage
    table = domain
    username_field = domain
    value_field = quota
}
map {
    pattern = priv/quota/messages
    table = quota2
    username_field = username
    value_field = messages
}
Next, the file /etc/dovecot/dovecot.conf needs the following changes to be made, this will allow Dovecot to be able to write the domain, and users mailboxes current quota sizes to the domain and quota2 tables respectively.add this the end of file.

#vim /etc/dovecot/dovecot.conf
mail_plugins = $mail_plugins quota
userdb {
    args = /etc/dovecot/dovecot-sql.conf.ext
    driver = sql
}
passdb {
    args = /etc/dovecot/dovecot-sql.conf.ext
    driver = sql
}
service dict {
    unix_listener dict {
        mode = 0600
        user = vmail
    }
}
protocol imap {
    mail_plugins = $mail_plugins imap_quota
}
plugin {
    # Using SQL Tables to store current quota size
    quota = dict:Quota:%d:proxy::sqldomainquota
    quota = dict:User Quota::proxy::sqluserquota
    # Allow 10% more for Trash Folder
    quota_rule2 = Trash:storage=+10%%
}
dict {
    sqluserquota = mysql:/etc/dovecot/dovecot-dict-sql-user.conf
    sqldomainquota = mysql:/etc/dovecot/dovecot-sql-domain.conf
}
To determine the quota limit, Dovecot retrieves these when it authenticates a POP3/IMAP account, against the mailbox and domain tables. Additional fields need to be retrieved from these tables to obtain the domain and/or user mailbox limits.
The/etc/dovecot/dovecot-sql.conf.ext needs to be amended as follows :

/etc/dovecot/dovecot-sql.conf.ext  no need to change coz we created in first step.

#service dovecot restart
Check the /var/log/syslog to see if the Dovecot service has successfully started. Also check the /var/log/mail.log to see if it is successfully processing imap calls.
then test send file attach with over quota size and check log: /var/log/syslog

Add check-quota-plugin display status in SquirrelMail
================
http://blog.shines.me.uk/configuring-domain-user-mailbox-quotas-in-dovecot-via-postfixadmin-on-ubuntu-12-04lts/