12345678910111213141516171819202122232425262728293031323334353637383940 |
- #!/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/' \
- -e 's/^\s*\(home_mailbox\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
- mynetworks = 127.0.0.1/32
- virtual_alias_maps = regexp:/etc/postfix/virtual_aliases
- virtual_alias_domains = accounts.hosting.com
- home_mailbox = Maildir/
- 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
|