Here are the simple steps I use to install Postfix on a Runcloud managed Ubuntu 16.04 server, as a basic “null client” for sending email only.
So that for example, I can receive WordPress system messages, and contact form submissions by email, while hosting my actual mailbox elsewhere.
And obviously this will work for self-managed servers too.
First you need to install mailutils, “swiss army knife of electronic mail handling” which should contain all the packages you need.
sudo apt-get update
sudo apt install mailutils
If postfix was never before installed on the system, you will be prompted with two simple questions after the packages has installed.
Otherwise, you’ll need to manually reconfigure the postfix package with;
sudo dpkg-reconfigure postfix
The recover method will ask 7 more questions in addition to the two first basic questions. Why, I don’t know. But here are all the answers;
- General type of mail configuration: Internet Site
- System mail name: [mydomain.com]
- Root and postmaster mail recipient: [blank] (configured later)
- Other destinations to accept mail for (blank for none): $myhostname, yourdomain.com, localhost.yourdomain.com, localhost
- Force synchronous updates on mail queue? No
- Local networks: 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
- Mailbox size limit (bytes): 0
- Local address extension character: +
- Internet protocols to use: all
Last but not least, I’ve made minimum edits to the postfix configuration file for basic email sending to work on WordPress, etc.
sudo nano /etc/postfix/main.cf
Edit these two lines;
- myhostname = yourdomain.com
- inet_interfaces = loopback-only
And finally do a restart on postfix;
sudo systemctl restart postfix
To forward system emails to an inbox elsewhere, edit aliases file;
sudo nano /etc/aliases
And edit these two lines like so;
For the above changes to take effect;
You can test both functions in command line;
echo "Receiving this email..?" | mail -s "Sending email!" email@example.com
echo "Message for system root" | mail -s "System Root" root
And if anything goes wrong, check the log for errors;
sudo less /var/log/mail.log
I recommend having a look at the configuration examples for Postfix for more options and fine tuning your null client. This guide is the most basic stuff only.
Thanks for reading and share if possible. Regards, David.
For questions about sending emails, go ahead!
Please note, Postfix is recommended over Sendmail.
And, I also advice against using this for sending emails to other mail boxes than your own, as they will likely end up marked as spam or junk email.