Setting Up Postfix Email Server
Most monitoring tools can send email notifications, so a local email server is quite helpful for testing. In this post, I used Red Hat Enterprise Linux 8.0 hosted on an Amazon EC2 instance.
First, I installed the postfix package:
dnf install -y postfix
Then, I edit the /etc/postfix/main.cf configuration file:
sudo sed -i "s/#myhostname = host.domain.tld/myhostname = $(hostname -f)/" /etc/postfix/main.cf
sudo sed -i "s/#mydomain = domain.tld/mydomain = ap-south-1.compute.internal/" /etc/postfix/main.cf
sudo sed -i "s/#myorigin = \$myhostname/myorigin = \$myhostname/" /etc/postfix/main.cf
sudo sed -i "s/#inet_interfaces = all/inet_interfaces = all/" /etc/postfix/main.cf
sudo sed -i "s/inet_interfaces = localhost/#inet_interfaces = localhost/" /etc/postfix/main.cf
sudo sed -i "s/#mynetworks_style = subnet/mynetworks_style = subnet/" /etc/postfix/main.cf
Finally, I send a test email with a CLI email client:
sudo dnf install -y mailx
mail ec2-user@ip-172-31-5-199.ap-south-1.compute.internal
mail
#1 #Read the first email
#d 1 #Delete the first email
#q #Quit the application