2007-03-24 08:27:00 +01:00
#
# Dovecot configuration for Postfix Admin
2009-01-15 12:38:11 +01:00
# Originally written by: Massimo <AndyCapp> Danieli
# Revised by: Sampsa Hario <shario> for Dovecot v1.0
2007-03-24 08:27:00 +01:00
#
2009-01-15 12:38:11 +01:00
More complete Dovecot documentation:
2007-03-24 08:27:00 +01:00
2009-01-15 12:38:11 +01:00
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 v1.0.x configuration for Postfixadmin setup.
2007-03-24 08:27:00 +01:00
Please refer to Dovecot documentation for complete information.
2009-01-15 12:38:11 +01:00
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.
2007-03-24 08:27:00 +01:00
2009-01-15 12:38:11 +01:00
1. Dovecot setup
-----------------
2009-11-03 22:58:40 +01:00
default_mail_env = maildir:/var/mail/vmail/%u/
2007-03-24 08:27:00 +01:00
2010-09-27 01:14:42 +02:00
(dovecot 1.0.7 calls this mail_location ... ie.. mail_location = maildir:/...../%u )
2009-01-15 12:38:11 +01:00
auth default {
2009-11-03 22:58:40 +01:00
mechanisms plain
2009-01-15 12:38:11 +01:00
userdb sql {
# Path for SQL configuration file, see doc/dovecot-sql-example.conf
args = /etc/dovecot-mysql.conf
}
passdb sql {
# Path for SQL configuration file, see doc/dovecot-sql-example.conf
args = /etc/dovecot-mysql.conf
}
}
2007-03-24 08:27:00 +01:00
# Valid UID range for users, defaults to 500 and above.
2009-01-15 12:38:11 +01:00
first_valid_uid = 1001 # Change this to your postfix UID
2007-03-24 08:27:00 +01:00
2. Dovecot mysql setup
----------------------
2009-01-15 12:38:11 +01:00
Below you'll find the relevant part of dovecot-mysql.conf file regarding our
setup. Things you may need to change are db_password, uid and gid:
2007-03-24 08:27:00 +01:00
2009-11-03 22:58:40 +01:00
2009-01-15 12:38:11 +01:00
connect = host=localhost dbname=postfix user=postfix password=postfix
2009-11-03 22:58:40 +01:00
driver = mysql
2007-03-24 08:27:00 +01:00
# Default password scheme.
2008-05-25 22:49:40 +02:00
# depends on your $CONF['encrypt'] setting:
# md5crypt -> MD5-CRYPT
# md5 -> PLAIN-MD5
# cleartext -> PLAIN
default_pass_scheme = MD5-CRYPT
2007-03-24 08:27:00 +01:00
2009-01-15 12:38:11 +01:00
# Query to retrieve password. user can be used to retrieve username in other
# formats also.
2007-03-24 08:27:00 +01:00
2009-01-15 12:38:11 +01:00
password_query = SELECT username AS user,password FROM mailbox WHERE username = '%u' AND active='1'
2007-03-24 08:27:00 +01:00
# Query to retrieve user information.
2009-01-15 12:38:11 +01:00
user_query = SELECT maildir, 1001 AS uid, 1001 AS gid FROM mailbox WHERE username = '%u' AND active='1'
2010-09-27 01:14:42 +02:00
for dovecot 1.2: (for PostgreSQL, replace 'CONCAT(a, b)' with 'a || b')
user_query = SELECT CONCAT('/home/vmail/', maildir) AS home, 1001 AS uid, 1001 AS gid,
CONCAT('*:bytes=', quota) AS quota_rule FROM mailbox WHERE username = '%u' AND active='1'
2009-01-15 12:38:11 +01:00
NB! The GID and UID are for postfix user and group ID, NOT MySQL user and group ID.
3. Dovecot v1.0 quota support (optional)
----------------------------------------
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 {
quota = dict:storage=200000 proxy::quota
}
## POP quota
protocol pop3 {
mail_plugins = quota
}
## Local Delivery Agent
protocol lda {
mail_plugins = quota
}
## Dictionary DB proxy
dict {
quota = mysql:/etc/dovecot-dict-quota.conf
}
## Default quota values
plugin {
quota = dict:storage=200000 proxy::quota
}
Change dovecot-mysql.conf to return quota values:
2009-11-28 23:12:54 +01:00
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'
2009-01-15 12:38:11 +01:00
Create file dovecot-dict-quota.conf:
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
Create database in Mysql:
2009-10-19 00:43:13 +02:00
(This is automatically done by postfixadmin's setup.php)
2009-01-15 12:38:11 +01:00
Enable quota support in Postfixadmin config.inc.php:
2007-03-24 08:27:00 +01:00
2009-01-15 12:38:11 +01:00
$CONF['used_quotas'] = 'YES';
$CONF['quota'] = 'YES';
2009-10-19 00:43:13 +02:00
Note: The above text describes the configuration for dovecot 1.0 & 1.1 quota table format.
If you use dovecot 1.2 or newer,
- use the 'quota2' table (also created by setup.php)
- set $CONF['new_quota_table'] = 'YES'
2013-12-01 22:48:14 +01:00