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
2014-01-02 18:09:54 +01:00
# Revised by: David Goodwin <david@palepurple.co.uk> for Dovecot 2.1.x (2014/01/02)
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
2014-01-02 18:09:54 +01:00
Here are the relevant parts of Dovecot v2.1.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
-----------------
2014-01-02 18:09:54 +01:00
A basic /etc/dovecot/dovecot.conf is as follows, this was generated using 'dovecot -n' on a vanilla install and then
changing to talk to a PostgreSQL or MySQL database.
# BEGIN /etc/dovecot/dovecot.conf:
# Change this to where your mail root is, this needs to match whatever structure postfix expects....
2018-02-02 15:23:53 +01:00
# See also: https://wiki.dovecot.org/MailLocation - %d domain, %u full username, %n user part (%u with no domain)
2014-01-02 18:09:54 +01:00
mail_location = maildir:/var/mail/vmail/%u/
2010-09-27 01:14:42 +02:00
2014-01-02 18:09:54 +01:00
namespace inbox {
inbox = yes
location =
mailbox Drafts {
special_use = \Drafts
}
mailbox Junk {
special_use = \Junk
}
mailbox Sent {
special_use = \Sent
2009-01-15 12:38:11 +01:00
}
2014-01-02 18:09:54 +01:00
mailbox "Sent Messages" {
special_use = \Sent
2009-01-15 12:38:11 +01:00
}
2014-01-02 18:09:54 +01:00
mailbox Trash {
special_use = \Trash
}
prefix =
}
protocols = "imap pop3"
2014-01-21 16:38:11 +01:00
# 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
2014-01-02 18:09:54 +01:00
ssl_key = </etc/dovecot/private/dovecot.pem
2014-01-21 16:38:11 +01:00
# login is for outlook express smtpd auth
auth_mechanisms = plain login
# If you're having trouble, try uncommenting these :
#auth_debug = yes
#auth_debug_passwords = yes
2014-01-02 18:09:54 +01:00
userdb {
driver = sql
args = /etc/dovecot/dovecot-sql.conf
2009-01-15 12:38:11 +01:00
}
2007-03-24 08:27:00 +01:00
2014-01-02 18:09:54 +01:00
passdb {
driver = sql
args = /etc/dovecot/dovecot-sql.conf
}
2014-01-21 16:38:11 +01:00
# 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
# }
#}
2014-01-02 18:09:54 +01:00
# Needs to match Postfix virtual_uid_maps
first_valid_uid = 1001
2014-01-21 16:38:11 +01:00
# allow plaintext auth (change to 'yes' to block plaintext passwords)
disable_plaintext_auth = no
2007-03-24 08:27:00 +01:00
2014-01-02 18:09:54 +01:00
#END
2007-03-24 08:27:00 +01:00
2014-01-02 18:09:54 +01:00
2. Dovecot *sql setup
2007-03-24 08:27:00 +01:00
----------------------
2014-01-02 18:09:54 +01:00
Below you'll find the relevant part of dovecot-sql.conf file regarding our
setup.
Things you will probably need to change are db connection settings (connect=)
and the default_pass_scheme.
2007-03-24 08:27:00 +01:00
2014-01-02 18:09:54 +01:00
#BEGIN /etc/dovecot/dovecot-sql.conf
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
2014-01-02 18:09:54 +01:00
# Use either
2009-11-03 22:58:40 +01:00
driver = mysql
2014-01-02 18:09:54 +01:00
# Or
# driver = pgsql
2007-03-24 08:27:00 +01:00
2014-01-02 18:09:54 +01:00
# Default password scheme - change to match your Postfixadmin setting.
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
2014-01-02 18:09:54 +01:00
# Query to retrieve user information, note uid matches dovecot.conf AND Postfix virtual_uid_maps parameter.
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'
2014-01-02 18:09:54 +01:00
# MYSQL :
2018-02-02 15:21:42 +01:00
user_query = SELECT CONCAT('/var/mail/vmail/', maildir) AS home, 1001 AS uid, 1001 AS gid,
2010-09-27 01:14:42 +02:00
CONCAT('*:bytes=', quota) AS quota_rule FROM mailbox WHERE username = '%u' AND active='1'
2014-01-02 18:09:54 +01:00
# PostgreSQL : (no Quota though) :
2014-01-21 15:55:11 +01:00
# user_query = SELECT '/var/vmail/mail/' || maildir AS home, 1001 as uid, 1001 as gid FROM mailbox WHERE username = '%u' AND active = '1'
2014-01-02 18:09:54 +01:00
#END /etc/dovecot/dovecot-sql.conf
2010-09-27 01:14:42 +02:00
2009-01-15 12:38:11 +01:00
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 {
2019-08-13 14:32:29 +02:00
mail_plugins = quota
2009-01-15 12:38:11 +01:00
}
## 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
}
2014-01-02 18:09:54 +01:00
Change dovecot-sql.conf to return quota values:
2009-01-15 12:38:11 +01:00
2009-11-28 23:12:54 +01:00
for MySQL:
2019-08-23 13:58:36 +02:00
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'
2009-11-28 23:12:54 +01:00
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