From 52810a2158f5c9af7cd4fbef11a903b27a79e7f1 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Tue, 6 Oct 2015 15:47:45 +0200
Subject: [PATCH] Enhance mail server config in server postinstall script.

---
 dotfiles_user_server/mailfilter |  2 ++
 dotfiles_user_server/muttrc     |  2 --
 jessie_start_server.sh          |  8 +++++---
 systemfiles/main.cf             | 20 ++++++++++++++++++++
 4 files changed, 27 insertions(+), 5 deletions(-)
 create mode 100644 dotfiles_user_server/mailfilter
 create mode 100644 systemfiles/main.cf

diff --git a/dotfiles_user_server/mailfilter b/dotfiles_user_server/mailfilter
new file mode 100644
index 0000000..ff041e0
--- /dev/null
+++ b/dotfiles_user_server/mailfilter
@@ -0,0 +1,2 @@
+DEFAULT="$HOME/mail/new_inbox/"
+logfile "$HOME/.mailfilter.log"
diff --git a/dotfiles_user_server/muttrc b/dotfiles_user_server/muttrc
index 6be1586..5c91d2e 100644
--- a/dotfiles_user_server/muttrc
+++ b/dotfiles_user_server/muttrc
@@ -21,8 +21,6 @@ unignore from: subject to cc date
 
 # Force some variables for From: and Message-ID: generation.
 set realname="Christian Heller"
-set from="c.heller@plomlompom.de"
-set hostname="plomlompom.de"
 
 # Allow me to reply myself.
 set reply_self = yes
diff --git a/jessie_start_server.sh b/jessie_start_server.sh
index 0f9746c..dcdfbf4 100755
--- a/jessie_start_server.sh
+++ b/jessie_start_server.sh
@@ -84,10 +84,12 @@ su plom -c 'mkdir -p /home/plom/.vimbackups/'
 # Set up openssh-server.
 apt-get -y install openssh-server
 
-# Set up mail client system.
-apt-get -y install getmail4 procmail mutt
-su plom -c 'mkdir -p /home/plom/mail'
+# Set up mail system.
+apt-get -y install getmail4 procmail mutt postfix maildrop
+su plom -c 'mkdir -p /home/plom/mail/'
 su plom -c 'mkdir -p /home/plom/mail/inbox/{cur,new,tmp}'
+su plom -c 'mkdir -p /home/plom/mail/new_inbox/{cur,new,tmp}'
+cp config/systemfiles/mail.cf /etc/postfix/main.cf
 
 # Set up screen.
 apt-get -y install screen
diff --git a/systemfiles/main.cf b/systemfiles/main.cf
new file mode 100644
index 0000000..4bc9749
--- /dev/null
+++ b/systemfiles/main.cf
@@ -0,0 +1,20 @@
+# /etc/postfix/main.cf
+
+# Use maildrop as MDA.
+mailbox_command = /usr/bin/maildrop
+
+# Restrictive relaying policy.
+smtpd_relay_restrictions = permit_mynetworks defer_unauth_destination
+
+# What domains to receive mail for: names of local server.
+mydestination = plomlompom.com, localhost
+
+# What clients to relay mail from: only local server.
+mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
+
+# Paranoid maximum error notification.
+notify_classes=2bounce, bounce, data, delay, policy, protocol, resource, software
+
+# Use opendkim at given port as mail filter.
+#non_smtpd_milters = inet:localhost:12301
+#smtpd_milters = inet:localhost:12301
-- 
2.30.2