We are using PAM for the passdb and LDAP for the userdb. We will also configure the LDA (Local delivery agent) because we will use dovecot for delivery as it is able to use sieve scripts. The configuration file /etc/dovecot/dovecot.conf could look similar to the following
protocols = imap imaps
disable_plaintext_auth = yes
syslog_facility = mail
passdb pam {
}
userdb ldap {
args = /etc/dovecot/dovecot-ldap.conf
}
We have to tell postfix that it should use dovecot for delivery be
editing /etc/postfix/main.cf
virtual_transport = dovecot
dovecot_destination_recipient_limit = 1
In the /etc/postfix/master.cf we have to create a service which is
called dovecot
dovecot unix - n n - - pipe
flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -d ${recipient}
Now dovecot is responsible for delivering.
LDAP interface configuration
With /etc/dovecot/dovecot-ldap.conf we configure where to find the
data in the LDAP directory for the userdb
hosts = localhost
base = ou=people, dc=example, dc=com
ldap_version = 3
scope = subtree
user_attrs = homeDirectory=home,mailbox=mail
user_filter = (|(uid=%u)(maildrop=%u))
user_global_uid = 110
user_global_gid = 110
Logrotate for LDA
If you use the log file like mentioned above you really should
configure logrotate to do the rotation. Else this file can get
really big. Do this by adding the file
/etc/logrotate.d/dovecot-deliver
/var/vmail/dovecot-deliver.log {
weekly
rotate 14
compress
}
Using sieve scripting for delivering
I've decided to use 2 kinds of sieve scripts. A global one for every
user who doesn't write his own and a per user
script. Therefore we edit /etc/dovecot/dovecot.conf to contain
protocol lda {
postmaster_address = postmaster@example.com
log_path = /var/vmail/dovecot-deliver.log
auth_socket_path = /var/run/dovecot/auth-master
mail_plugins = cmusieve # that's for the sieve scripting
}
socket listen {
master {
path = /var/run/dovecot/auth-master
mode = 0600
user = vmail
}
}
plugin {
sieve_global_path = /var/vmail/globalsieverc
sieve=/var/vmail/sieve/%n.%d.sieve
}
Now we can create the global script
touch /var/vmail/globalsieverc
chown vmail: /var/vmail/globalsieverc
and edit /var/vmail/globalsieverc to contain something like
require ["fileinto"];
# Move spam to spam folder
if anyof ( header :contains "X-Spam-Flag" "YES",
header :contains "Subject" "***SPAM***" ) {
fileinto "spam";
stop;
}
If you want to use you own per user script you might create a file
like /var/vmail/sieve/michael.derhammer.net.sieve. This should be
readable by dovecot and overwrites the global one.