Mail relays are common to networks to facilitate alerting, etc. In Windows environments, IIS SMTP relay is often used, but Postfix could be used as well.
We’ll walk through how to configure an outgoing Postfix as an outbound mail relay on Ubuntu 16.04.
sudo apt-get update sudo DEBIAN_PRIORITY=low apt-get install postfix
Enter the domain from which your messages will come. Technically, this doesn’t have to be a domain you own. However, you will have problems with delivery if it isn’t (messages going to junk mail, etc). Also, unless you’ve configured for it, you could run into problems with some systems, configuring your receiving domain here. Also, it’s recommended configure the SPF record accordingly.
The next step is not relevant to our configuration as we are not intending to recieve mail, but we’ll specify my username, justin, as the catchall for postmaster, root, and other system accounts.
As we receive the prompt for any domains that should be considered the final destination, we’ll clear this line. All mail will go externally.
We’ll select ‘No’ for synchronous updates and move along…
Next we’ll select the IPs from which relaying will be allowed. This should be locked down as much as possible, ideally only using the IPs of the individual systems that need to relay. Below I’ve specified the entire subnet 192.168.1.0/24 for this example.
Next, we’re prompted for mailbox size limit. As we aren’t doing any local delivery, this isn’t a necessary parameter and is ok to leave at 0.
We could select a character for a local address extension, but again, as we are not configuring for local delivery, this setting is irrelevant.
Finally, we’ll configure what protocol the server is listening in on. I’m opting for IPv4 as IPv6 is common in environments I manage at this time.
And for testing, I’ll hop on a Windows box and use the send-mailmessage.
Not working for you? You can relaunch Postfix Configuration with:
sudo dpkg-reconfigure postfix
Or you can simply review the config file at /etc/postfix/main.cf.