From: Jer (on server) <jer@pley.net>
Date: Wed, 30 Nov 2016 22:40:07 +0000 (+0000)
Subject: Add dovecot support
X-Git-Url: http://105106.c2e0p.group/postfix.git/commitdiff_plain/04cc8df19762366dfb7f00bfaade105520d45692?ds=sidebyside;hp=6e5d449e15a8544549b3d2c9b941f4e461f7e2e0

Add dovecot support
---

diff --git a/Makefile b/Makefile
index 6183414..7022fae 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-SUBDIRS := postfix postfixadmin 
+SUBDIRS := postfix postfixadmin dovecot
 
 all: $(SUBDIRS)
 .PHONY: $(SUBDIRS)
diff --git a/dovecot/Makefile b/dovecot/Makefile
new file mode 100644
index 0000000..ba757e7
--- /dev/null
+++ b/dovecot/Makefile
@@ -0,0 +1,11 @@
+DST := /etc/dovecot
+
+INPUTS := dovecot-sql.conf.ext local.conf
+
+OUTPUTS := $(INPUTS:%=$(DST)/%)
+
+all: $(OUTPUTS)
+
+$(DST)/%: configuration/%
+	@mkdir -p $(@D)
+	cp $^ $@
diff --git a/dovecot/dovecot-sql.conf.ext b/dovecot/dovecot-sql.conf.ext
new file mode 100644
index 0000000..8ef9ae7
--- /dev/null
+++ b/dovecot/dovecot-sql.conf.ext
@@ -0,0 +1,4 @@
+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'
diff --git a/dovecot/local.conf b/dovecot/local.conf
new file mode 100644
index 0000000..d10ccfa
--- /dev/null
+++ b/dovecot/local.conf
@@ -0,0 +1,45 @@
+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
+  postmaster_address = postmaster@pley.net
+}
+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
+}