From a62062c382ef47abe49acf5805b8e8ccddcf0da0 Mon Sep 17 00:00:00 2001 From: Kai Ren Date: Mon, 24 Oct 2016 16:03:08 +0300 Subject: [PATCH] make Postfix -> Dovecot delivery over LMTP (was LDA) (#305) (#360) --- Dockerfile | 1 + target/dovecot/10-master.conf | 3 ++- target/dovecot/20-lmtp.conf | 19 +++++++++++++++++++ target/postfix/main.cf | 6 +----- target/postfix/master.cf | 8 +------- test/tests.bats | 2 +- 6 files changed, 25 insertions(+), 14 deletions(-) create mode 100644 target/dovecot/20-lmtp.conf diff --git a/Dockerfile b/Dockerfile index 98f220d3..231f03ea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,6 +13,7 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update -q --fix-missing && \ curl \ dovecot-core \ dovecot-imapd \ + dovecot-lmtpd \ dovecot-managesieved \ dovecot-pop3d \ dovecot-sieve \ diff --git a/target/dovecot/10-master.conf b/target/dovecot/10-master.conf index 48707827..059c3eb3 100644 --- a/target/dovecot/10-master.conf +++ b/target/dovecot/10-master.conf @@ -47,7 +47,8 @@ service pop3-login { service lmtp { unix_listener lmtp { - #mode = 0666 + mode = 0660 + group = postfix } # Create inet listener only if you can't use the above UNIX socket diff --git a/target/dovecot/20-lmtp.conf b/target/dovecot/20-lmtp.conf new file mode 100644 index 00000000..29c08bd6 --- /dev/null +++ b/target/dovecot/20-lmtp.conf @@ -0,0 +1,19 @@ +## +## LMTP specific settings +## + +# Support proxying to other LMTP/SMTP servers by performing passdb lookups. +#lmtp_proxy = no + +# When recipient address includes the detail (e.g. user+detail), try to save +# the mail to the detail mailbox. See also recipient_delimiter and +# lda_mailbox_autocreate settings. +#lmtp_save_to_detail_mailbox = no + +# Verify quota before replying to RCPT TO. This adds a small overhead. +#lmtp_rcpt_check_quota = no + +protocol lmtp { + # Space separated list of plugins to load (default is global mail_plugins). + mail_plugins = $mail_plugins sieve +} diff --git a/target/postfix/main.cf b/target/postfix/main.cf index 158cfa17..e76ec01d 100644 --- a/target/postfix/main.cf +++ b/target/postfix/main.cf @@ -58,14 +58,10 @@ smtpd_sasl_local_domain = $myhostname broken_sasl_auth_clients = yes # Mail directory -virtual_mailbox_base = /var/mail +virtual_transport = lmtp:unix:/var/run/dovecot/lmtp virtual_mailbox_domains = /etc/postfix/vhost virtual_mailbox_maps = hash:/etc/postfix/vmailbox virtual_alias_maps = hash:/etc/postfix/virtual -virtual_uid_maps = static:5000 -virtual_gid_maps = static:5000 -# Enable Dovecot Sieve -virtual_transport = dovecot # Additional option for filtering content_filter = smtp-amavis:[127.0.0.1]:10024 diff --git a/target/postfix/master.cf b/target/postfix/master.cf index 659a5237..dc54f964 100644 --- a/target/postfix/master.cf +++ b/target/postfix/master.cf @@ -45,7 +45,7 @@ retry unix - - - - - error discard unix - - - - - discard local unix - n n - - local virtual unix - n n - - virtual -lmtp unix - - - - - lmtp +lmtp unix - - n - - lmtp anvil unix - - - - 1 anvil scache unix - - - - 1 scache @@ -63,12 +63,6 @@ mailman unix - n n - - pipe flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py ${nexthop} ${user} -# -# Dovecot LDA configuration -# - -dovecot unix - n n - - pipe - flags=DRhu user=docker argv=/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop} -m ${extension} # # Amavis configuration diff --git a/test/tests.bats b/test/tests.bats index d3b79d74..875fbf03 100644 --- a/test/tests.bats +++ b/test/tests.bats @@ -149,7 +149,7 @@ } @test "checking smtp: delivers mail to existing account" { - run docker exec mail /bin/sh -c "grep 'status=sent (delivered via dovecot service)' /var/log/mail/mail.log | wc -l" + run docker exec mail /bin/sh -c "grep 'postfix/lmtp' /var/log/mail/mail.log | grep 'status=sent' | grep ' Saved)' | wc -l" [ "$status" -eq 0 ] [ "$output" -eq 6 ] }