DOVECOT
DOVECOT
http://wiki.dovecot.org/Quota
http://wiki.dovecot.org/Quota/Dict
http://www.opensourcehowto.org/how-to/mysql/mysql-users-postfixadmin-postfix-
dovecot--squirrelmail-with-userprefs-stored-in-mysql.html
Here are the relevant parts of Dovecot v2.1.x configuration for Postfixadmin setup.
The setup gets userdb and passdb info from MySQL as well as quotas, and
uses dict backend to store used quotas as key=value pairs so that they can
be viewed real-time in Postfixadmin.
1. Dovecot setup
-----------------
# BEGIN /etc/dovecot/dovecot.conf:
# Change this to where your mail root is, this needs to match whatever structure
postfix expects....
# See also: https://wiki.dovecot.org/MailLocation - %d domain, %u full username, %n
user part (%u with no domain)
mail_location = maildir:/var/mail/vmail/%u/
namespace inbox {
inbox = yes
location =
mailbox Drafts {
special_use = \Drafts
}
mailbox Junk {
special_use = \Junk
}
mailbox Sent {
special_use = \Sent
}
mailbox "Sent Messages" {
special_use = \Sent
}
mailbox Trash {
special_use = \Trash
}
prefix =
}
protocols = "imap pop3"
# change to 'no' if you don't have ssl cert/keys, and comment out ssl_cert/ssl_key
ssl = yes
ssl_cert = </etc/dovecot/private/dovecot.pem
ssl_key = </etc/dovecot/private/dovecot.pem
userdb {
driver = sql
args = /etc/dovecot/dovecot-sql.conf
}
passdb {
driver = sql
args = /etc/dovecot/dovecot-sql.conf
}
# Uncomment this if you want Postfix to be able to do smtpd auth through dovecot
# At a minimum Postfix probably needs smtpd_sasl_type = dovecot
# And additionally: smtpd_sasl_path = private/auth
#service auth {
# unix_listener /var/spool/postfix/private/auth {
# mode = 0660
# user = postfix
# group = postfix
# }
#}
#END
Things you will probably need to change are db connection settings (connect=)
and the default_pass_scheme.
#BEGIN /etc/dovecot/dovecot-sql.conf
# Query to retrieve user information, note uid matches dovecot.conf AND Postfix
virtual_uid_maps parameter.
# MYSQL:
user_query = SELECT CONCAT('/var/mail/vmail/', maildir) AS home, 1001 AS uid, 1001
AS gid, CONCAT('*:bytes=', quota) AS quota_rule FROM mailbox WHERE username = '%u'
AND active='1'
# PostgreSQL:
# user_query = SELECT '/var/mail/vmail/' || maildir AS home, 1001 AS uid, 1001 AS
gid,
# '*:bytes=' || quota AS quota_rule FROM mailbox WHERE username = '%u' AND active
= '1'
# see: https://doc.dovecot.org/configuration_manual/authentication/sql/#id6
iterate_query = SELECT username as user FROM mailbox WHERE active = '1'
#END /etc/dovecot/dovecot-sql.conf
If you make use of the separate smtp_active flag in the mailbox table of
postfixadmin by
enabling the configuration parameter $CONF['smtp_active_flag'] = YES in
postfixadmin configuration
and you're using dovecot sasl with postfix, the dovecot queries can be updated to
use the different flag for smtp:
With Dovecot 2.3.11 (ish?), if you are using the Postfixadmin dovecot password
hashing backend - so your Postfixadmin configuration looks like
`$CONF['encrypt'] = 'dovecot:something';`
then the system user account running the PostfixAdmin code (normally the webserver
user
account, like www-data or http or nobody) will need ...
Please note, Postfixadmin does not need to run on the same server as the Dovecot
server.
See also the following tickets which contain discussions and solutions :
Please note that you need to use Dovecot's own local delivery agent to
enforce and update quotas. Then you can view real-time used quotas in
Postfixadmin.
Add to dovecot.conf:
## IMAP quota
protocol imap {
mail_plugins = quota
}
## POP quota
protocol pop3 {
mail_plugins = quota
}
## Dictionary DB proxy
dict {
quota = mysql:/etc/dovecot-dict-quota.conf
}
for MySQL:
user_query = SELECT maildir, 1001 AS uid, 1001 AS gid,
CONCAT('dict:storage=',floor(quota/1000),' ::proxy::quota') as quota FROM mailbox
WHERE username = '%u' AND active='1'
for PostgreSQL:
user_query = SELECT maildir, 1001 AS uid, 1001 AS gid, 'dict:storage=' ||
floor(quota/1000) || '::proxy::quota' as quota FROM mailbox WHERE username = '%u'
AND active='1'
driver = mysql
connect = host=localhost dbname=postfix user=postfix password=postfix
default_pass_scheme = MD5-CRYPT
table = quota
select_field = current
where_field = path
username_field = username
$CONF['used_quotas'] = 'YES';
$CONF['quota'] = 'YES';
Note: The above text describes the configuration for dovecot 1.0 & 1.1 quota table
format.