home · contact · privacy
Improve mail setup.
authorChristian Heller <c.heller@plomlompom.de>
Mon, 3 Dec 2018 09:50:19 +0000 (10:50 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Mon, 3 Dec 2018 09:50:19 +0000 (10:50 +0100)
all_new_2018/letsencrypt_remote.sh
all_new_2018/linkable_etc_files/mail/etc/dovecot/conf.d/99-auth.conf [new file with mode: 0644]
all_new_2018/linkable_etc_files/mail/etc/dovecot/conf.d/99-lmtp.conf [new file with mode: 0644]
all_new_2018/linkable_etc_files/mail/etc/dovecot/conf.d/99-master.conf
all_new_2018/linkable_etc_files/mail/etc/postfix/main.cf
all_new_2018/setup_mail.sh

index 18f9aa4f0d50d9aa494d97aef328d045ff78387b..6b7b54f17ae41e4fecd043e519f60cb667b19a0e 100755 (executable)
@@ -28,7 +28,7 @@ if [ "${action}" = "get" ]; then
 elif [ "${action}" = "put" ]; then
     # Expand letsencrypt.tar to /etc/letsencrypt/ on server.
     scp letsencrypt.tar plom@${server}:~/
-    ssh -t plom@${server} 'su -c "rmdir /etc/letsencrypt && mv letsencrypt.tar /etc/ && cd /etc/ && tar xf letsencrypt.tar && rm letsencrypt.tar"'
+    ssh -t plom@${server} 'su -c "apt -y install certbot && rmdir /etc/letsencrypt && mv letsencrypt.tar /etc/ && cd /etc/ && tar xf letsencrypt.tar && rm letsencrypt.tar"'
 else
     echo "Action must be 'get', or 'put'."
     false
diff --git a/all_new_2018/linkable_etc_files/mail/etc/dovecot/conf.d/99-auth.conf b/all_new_2018/linkable_etc_files/mail/etc/dovecot/conf.d/99-auth.conf
new file mode 100644 (file)
index 0000000..4a8549c
--- /dev/null
@@ -0,0 +1,3 @@
+# This is only necessary when we use dovecot's LMTP mechanism to receive
+# mail from postfix.
+auth_username_format = %Ln
diff --git a/all_new_2018/linkable_etc_files/mail/etc/dovecot/conf.d/99-lmtp.conf b/all_new_2018/linkable_etc_files/mail/etc/dovecot/conf.d/99-lmtp.conf
new file mode 100644 (file)
index 0000000..097f04e
--- /dev/null
@@ -0,0 +1,4 @@
+# Add sieve filtering.
+protocol lmtp {
+  mail_plugins = $mail_plugins sieve
+}
index 0871740688ad08649615525ee8f7bcaac8423e38..f8c5b4393d2e88655009a76003069c32b9061e59 100644 (file)
@@ -8,3 +8,13 @@ service auth {
        group = postfix
   }
 }
+
+# We don't strictly need to provide a LMTP server to fetch mail from
+# postfix, but we do if we want to do sophisticated stuff like sieve
+# filtering on the way.
+service lmtp {
+  inet_listener lmtp {
+    address = 127.0.0.1
+    port = 2424
+  }
+}
index 39d3720aeb9d1ed2498e117a309680d06905fa1f..7074961920965bc4104695cd6892f10668682677 100644 (file)
@@ -50,4 +50,10 @@ smtpd_sasl_path = private/auth
 
 # connect to opendkim
 smtpd_milters = inet:localhost:12301
-non_smtpd_milters = inet:localhost:12301
\ No newline at end of file
+non_smtpd_milters = inet:localhost:12301
+
+# transport mail to dovecot; not strictly needed, as even without this
+# postfix will throw mail to /var/mail/USER to be found by dovecot for
+# serving via IMAP etc.; but using dovecot's LMTP server for delivery
+# allows us to do stuff like dovecot-side sieve filtering.
+mailbox_transport = lmtp:inet:127.0.0.1:2424
\ No newline at end of file
index edd53194624ccd343e1d685f1dacd037c3350830..18d7c310719bc5aea4b2eab8f83e15e2ebe9eba5 100755 (executable)
@@ -53,8 +53,12 @@ echo "ssl_key = </etc/letsencrypt/live/$(hostname -f)/privkey.pem" >> /etc/dovec
 echo "postfix postfix/mailname string ${mail_domain}" | debconf-set-selections
 echo "${mail_domain}" > /etc/mailname
 
-# Everything should now be ready for installations.
-apt install -y -o Dpkg::Options::=--force-confold postfix dovecot-imapd opendkim
+# Everything should now be ready for installations. Note that we don't
+# strictly need dovecot-lmtpd, as postfix will deliver mail to /var/mail/USER
+# in any case, to be found by dovecot; we use it as a transport mechanism to
+# allow for sophisticated stuff like dovecot-side sieve filtering (installed
+# with dovecot-sieve).
+apt install -y -o Dpkg::Options::=--force-confold postfix dovecot-imapd dovecot-lmtpd dovecot-sieve opendkim
 echo "TODO: Ensure MX entry for your system in your DNS configuration."
 echo "TODO: Ensure a proper SPF entry for this system in your DNS configuration; something like 'v=spf1 mx -all' mapped to your host."
 if [ "${add_dkim_record}" -eq "1" ]; then