Instead of using postconf command line tool I prefer to edit /etc/postfix/mail.cf, because there are some example configurations in the file so I don’t have to mock up commands and steps.
Mail Server Configuration
Package to be installed:
#postfix should be preinstalled with centos7 Linux.
yum -y install postfix
#Enable on startup
systemctl enable postfix
#modify following parameters
#to accept mail traffice from all hosts
# to accept mail from your domain. For example: from shiba.local in my
# example of IPA Server (authentication server).
# $mydomain variable will give domain portion of the mail server.
myorigin = $mydomain
#accept traffic from 10.0.0.0/24 subnet only
#accept traffic for $mydomain destination
Configuring null client (to forward mail to SMTP server)
#find relayhost and give ip/DNS host name in it. mail.shiba.local is my mail server which
# was configured in above step.
#it is default you don’t have to modify
#by default it is not set to any subnet, which should work, but if you are ask to set
# target network to localhost only you have to do it
#if you are ask to define destination domain, you have to do it otherwise you can avoid this line
Alternatively use postconf command -e option is to edit config:
postconf -e ‘relayhost=[mail.shiba.local]’
postconf -e “inet_interface=loopback-only”
postconf -e “mynetwork=127.0.0.0/8″
postconf -e “mydestination=”
Note: You are only working with client side of mail server. So you don’t have to configure SELinux and Firewall to allow inbound mail configuration. Also note if you are only using IPv4, then don’t forget to set inet_protocols=ipv4 instead of inet_protocols=all.
Sending mail from null mail client:
From the client Linux machine where you have configured null mail client type following commands
echo “test mail” > myfile.txt
mail -s “test mail” email@example.com < myfile.txt
You can view mail log to verify if there is any issue in mail delivary:
tail -f /var/log/maillog
To Verifying mail in mail server:
1. Switch to the user
su – shiba
2. check mail using mail command
if you got mail in the server, you can enter mail id number shown in the list to view content of the mail. to quit from mail client press q.