From 145faa59bb40d58a64bc5dc296ccace335753a14 Mon Sep 17 00:00:00 2001 From: Kiina Date: Mon, 30 May 2016 15:01:51 +0200 Subject: [PATCH] Add sieve mailfiltering --- README.md | 1 + dovecot/90-sieve.conf | 6 ++++++ dovecot/Dockerfile | 10 +++++++++- dovecot/default.sieve.example | 12 ++++++++++++ dovecot/dovecot.lda | 2 +- 5 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 dovecot/90-sieve.conf create mode 100644 dovecot/default.sieve.example diff --git a/README.md b/README.md index 48d3103..b2ddc93 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ Setup cp mail-base/aliases.example mail-base/aliases cp mail-base/domains.example mail-base/domains cp mail-base/passwords.example mail-base/passwords + cp dovecot/default.sieve.example dovecot/default.sieve 2) Add all domains you want to receive mail for to the file `mail-base/domains`, like this: diff --git a/dovecot/90-sieve.conf b/dovecot/90-sieve.conf new file mode 100644 index 0000000..82e6e76 --- /dev/null +++ b/dovecot/90-sieve.conf @@ -0,0 +1,6 @@ +plugin { + sieve = ~/.dovecot.sieve + sieve_global_path = /var/lib/dovecot/sieve/default.sieve + sieve_dir = ~/sieve + sieve_global_dir = /var/lib/dovecot/sieve/ +} diff --git a/dovecot/Dockerfile b/dovecot/Dockerfile index 64eca6d..8ad822a 100644 --- a/dovecot/Dockerfile +++ b/dovecot/Dockerfile @@ -10,6 +10,10 @@ RUN apt-get update \ postgrey \ # Install dovecot as IMAP server dovecot-imapd \ + # Install sieve for mail filtering + dovecot-sieve \ + # Install sieve for mail filtering + dovecot-managesieved \ && rm -rf /var/lib/apt/lists/* # postfix configuration @@ -18,6 +22,11 @@ ADD ./postfix.main.cf /etc/postfix/main.cf ADD ./postfix.master.cf.append /etc/postfix/master-additional.cf RUN cat /etc/postfix/master-additional.cf >> /etc/postfix/master.cf +# sieve configuration +ADD ./default.sieve /var/lib/dovecot/sieve/default.sieve +RUN sievec /var/lib/dovecot/sieve/default.sieve +ADD ./90-sieve.conf /etc/dovecot/conf.d/90-sieve.conf + # configure mail delivery to dovecot #ADD ./aliases /etc/postfix/virtual #ADD ./domains /etc/postfix/virtual-mailbox-domains @@ -66,4 +75,3 @@ EXPOSE 587 # start necessary services for operation (dovecot -F starts dovecot in the foreground to prevent container exit) ENTRYPOINT chown -R vmail:vmail /srv/vmail; service rsyslog start; service postgrey start; service postfix start; dovecot -F - diff --git a/dovecot/default.sieve.example b/dovecot/default.sieve.example new file mode 100644 index 0000000..3f92b20 --- /dev/null +++ b/dovecot/default.sieve.example @@ -0,0 +1,12 @@ +require ["vacation"]; +if address :is ["From", "To"] "example@example.org" { +vacation + # Reply at most once a day to a same sender + :days 1 + :subject "Out of Office" + # List of additional recipient addresses which are included in the auto replying. + # If a mail's recipient is not the envelope recipient and it's not on this list, + # no vacation reply is sent for it. + :addresses ["example@example.org"] + "Im out of office"; +} diff --git a/dovecot/dovecot.lda b/dovecot/dovecot.lda index b075d2f..a71b7af 100644 --- a/dovecot/dovecot.lda +++ b/dovecot/dovecot.lda @@ -1,5 +1,5 @@ protocol lda { hostname = mail.docker.container postmaster_address = postmaster@mail.docker.container - mail_plugin_dir = /usr/lib/dovecot/modules/lda + mail_plugins = $mail_plugins sieve }