-SUBDIRS := postfix postfixadmin
+SUBDIRS := postfix postfixadmin dovecot
all: $(SUBDIRS)
.PHONY: $(SUBDIRS)
--- /dev/null
+DST := /etc/dovecot
+
+INPUTS := dovecot-sql.conf.ext local.conf
+
+OUTPUTS := $(INPUTS:%=$(DST)/%)
+
+all: $(OUTPUTS)
+
+$(DST)/%: configuration/%
+ @mkdir -p $(@D)
+ cp $^ $@
--- /dev/null
+driver = mysql
+connect = host=localhost dbname=postfix user=dovecot password=dovecot
+user_query = SELECT concat('/var/spool/vmail/', maildir) as home, concat('maildir:/var/spool/vmail/', maildir) as mail, 101 AS uid, 12 AS gid, concat('maildir:storage=', quota) AS quota, concat('/var/spool/vmail/', maildir) as sieve_dir, concat('/var/spool/vmail/', maildir, 'dovecot.sieve') as sieve FROM mailbox WHERE username = '%u' AND active = '1'
+password_query = SELECT username as user, password, concat('/var/spool/vmail/', maildir) as userdb_home, concat('maildir:/var/spool/vmail/', maildir) as userdb_mail, 101 as userdb_uid, 12 as userdb_gid FROM mailbox WHERE username = '%u' AND active = '1'
--- /dev/null
+auth_mechanisms = plain
+mail_location = maildir:/var/spool/vmail/%d/%n
+mbox_write_locks = fcntl
+ssl = required
+disable_plaintext_auth = yes
+syslog_facility = local1
+verbose_proctitle = yes
+protocols = imap sieve pop3
+listen = *
+
+mail_max_userip_connections = 50
+
+protocol lda {
+ info_log_path = /var/log/dovecot-lda.log
+ mail_plugins = quota sieve
+}
+protocol imap {
+ mail_plugins = quota
+}
+service auth {
+ unix_listener auth-master {
+ mode = 0660
+ user = vmail
+ group = mail
+ }
+ unix_listener auth-client {
+ mode = 0660
+ user = postfix
+ group = mail
+ }
+ unix_listener auth-userdb {
+ mode = 0660
+ user = vmail
+ group = mail
+ }
+}
+passdb {
+ args = /etc/dovecot/dovecot-sql.conf.ext
+ driver = sql
+}
+userdb {
+ args = /etc/dovecot/dovecot-sql.conf.ext
+ driver = sql
+}