|
@@ -1,8 +1,13 @@
|
|
|
+#!/bin/bash
|
|
|
+
|
|
|
+# Ensure we are up-to-date and have postfix installed
|
|
|
yum update -y
|
|
|
yum install postfix -y
|
|
|
|
|
|
+# Create user for handling mail
|
|
|
useradd -m -s /sbin/nologin incoming
|
|
|
|
|
|
+# Remove defaults that may interfere
|
|
|
sed -i -e 's/^\s*\(inet_interfaces\s*=\)/#\1/' \
|
|
|
-e 's/^\s*\(mydestination\s*=\)/#\1/' \
|
|
|
-e 's/^\s*\(mynetworks\s*=\)/#\1/' \
|
|
@@ -10,6 +15,7 @@ sed -i -e 's/^\s*\(inet_interfaces\s*=\)/#\1/' \
|
|
|
-e 's/^\s*\(alias_maps\s*=\)/#\1/' \
|
|
|
/etc/postfix/main.cf
|
|
|
|
|
|
+# Configure postfix
|
|
|
cat <<EOF >> /etc/postfix/main.cf
|
|
|
# HOSTING CONFIG FOR EMAIL PARSING
|
|
|
inet_interfaces = all
|
|
@@ -17,14 +23,18 @@ mynetworks = 127.0.0.1/32
|
|
|
virtual_alias_maps = regexp:/etc/postfix/virtual_aliases
|
|
|
virtual_alias_domains = accounts.hosting.com
|
|
|
home_mailbox = Maildir/
|
|
|
-smtpd_reject_unlisted_recipient = no
|
|
|
EOF
|
|
|
|
|
|
+# Disable ALL bounces
|
|
|
+sed -i 's/^\(.*\)bounce$/\1discard/' /etc/postfix/master.cf
|
|
|
+
|
|
|
+# Write aliases for users we want to handle mail for
|
|
|
cat <<EOF > /etc/postfix/virtual_aliases
|
|
|
/^[0-9]+-[0-9]+@accounts\.hosting\.com$/ incoming
|
|
|
/^support@accounts\.hosting\.com$/ incoming
|
|
|
EOF
|
|
|
|
|
|
+# Restart postfix
|
|
|
systemctl restart postfix
|
|
|
|
|
|
|