blog.cjtrowbridge.com

VPS Setup: Email Server

February 21, 2016

This is a subpost of the larger post Updated Comprehensive VPS Setup Documentation. Many of my apps send lots of emails, so I usually need to setup a local outbound email server. Secure the port with iptables -A INPUT -i eth0 -j REJECT -p tcp --dport 25Install postfix for the server apt-get -y install postfix && apt-get -y install mailutilsNow edit the config files and change the interface to loopback-only like so; nano /etc/postfix/main.cfFind this line; inet_interfaces =And change to; inet_interfaces = 127.0.0.1Now edit the email aliases; nano /etc/aliasesAt the end of the file, make sure there is a line that starts with root and ends with your email, like so; root email@domain.comSave the file and exit. Then run newaliases to let Postfix apply the changes. Restarting Postfix is not enough because we changed the interfaces line in the config file. We need to stop and start it like so; postfix stoppostfix start