How Do You Set up a Send-Only (Postfix) Email Server on a Linux RHEL AWS Instance?

Problem scenario
You have a monitoring tool on a RedHat Enterprise Linux server that needs to send out emails upon certain events happening. You want to install and configure an email server. You need to send outbound emails, but you do not need to receive inbound emails. How do you configure RHEL to be able to send out regular emails over the internet?

This assumes that Postfix has been installed. For Debian/Ubuntu Linux, postfix is often installed by default. If it is not, run this command:
sudo apt -y install postfix # accept the various options by mostly accepting the defaults and using your best judgement

1. Ensure that the AWS Security Group allows for outbound connectivity over port 25.
2. Log into the RHEL server.
3. Run this command: hostname -f
4. Find the internal IP address. It is usually in the FQDN of an AWS server. You could run this command (and ignore the /20 at the end of its output):

ip addr show | grep eth0 | grep inet | awk '{print $2}'

You'll need this later.

5. Edit the /etc/postfix/ file (e.g., with sudo vi /etc/postfix/ It should have lines like these at the very end (but replace with FQDN of the server and replace with the internal IP address as found in steps 3 and 4 above).

inet_interfaces = localhost,
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, $mydomain
myhostname =

6. Now that the last lines of the file have been updated and the file is saved, restart the postfix server. Run this command:

sudo service postfix restart

7. If you have a DNS server so the FQDN resolves, skip this step. Otherwise update the /etc/hosts file to have an entry like this (where FQDN is the one found in step 3 and where is the internal IP address as found in step 4): FQDN

8. Optional step. Test it. Type in the following but replace below with your mail server's FQDN and press enter after each line:

sudo yum -y install telnet
telnet 25
mail from:
rcpt to:
This is just a test.

Another Possible Solution
Another way to do this is with Python; to learn how to use Python and not install anything else, see this external posting.

Leave a comment

Your email address will not be published. Required fields are marked *