Chapter 11. Mail Transport Agent
Mail Transport Agent (MTA) transports email messages between hosts using SMTP. The delivery of email messages can include several MTAs while reaching their destination. During the process of message delivery, the usage of MTA depends on the MTAs or the access configuration of the network.
Sendmail and Postfix are the two MTAs offered by RHEL.
Sendmail is available through the
AppStream repository. Sendmail is not a Message User Agent (MUA). You cannot browse and manage your incoming mail through a user interface, but it can work as an SMTP client. The
sendmail.mc package helps to reconfigure the Sendmail.
11.2. Installing Sendmail
To install Sendmail, perform the following steps:
Update all the installed packages with the latest version, so that all the dependent packages are updated
# yum update
# yum install sendmail
Use sendmail command to send email via command line
For Example: # echo "This is a test email" | sendmail -s "Test Email" email@example.com
Verify sendmail is installed
$ rpm -qa | grep sendmail
A Postfix transfer agent handles all processes related to mail delivery. Postfix is available through the
BaseOS repository. However,
postfix-ldap subpackages are built from the postfix source RPM that is available through the
Postfix configuration files are stored in the
Following is a list of the commonly used files:
- access:— it is used for access control and specifies hosts that are allowed to connect to Postfix.
- main.cf:— it is the global Postfix configuration file, and specifies many configuration options.
- master.cf:— it specifies Postfix interaction with various processes to accomplish mail delivery.
transport:— it maps email addresses to relay hosts. The aliases file is a configurable list required by the mail protocol that describes user ID aliases. It is in the
/etcdirectory and is shared between Postfix and Sendmail.
11.4. Installing Postfix
If the mail server package is not selected during the system installation, Postfix will not be available by default. Perform the following steps to install Postfix:
- Registering your system
Disabling and removing Sendmail
To disable and remove Sendmail
# yum remove sendmail
- Configuring firewall for sending and receiving emails
To install postfix
# yum install postfix
To start and enable the postfix service
# systemctl start postfix # systemctl enable postfix
Verify if the postfix service is running
$ rpm -qa | grep postfix
Restart the postfix service, in the following scenarios:
- if the output is stopped/waiting or not running
after changing any options in the configuration files under the /etc/postfix/ directory in order for those changes to take effect
# service postfix restart
11.5. Configuring Postfix
main.cf is the global Postfix configuration file and specifies many configuration options.
Following are few options you can add in the
/etc/postfix/main.cf file to configure Postfix:
host.domain.tldwith the mail server’s hostname.
For example: myhostname = mail.example.com
domain.tldwith the domain mail server.
For example: mydomain = example.comNote
With correct DNS setups, the myhostname and mydomain options should be autodetected and set automatically without user intervention.
mail_spool_directory:- allows specifying the location of the mailbox files.
For example: mail_spool_directory = /var/mail
- mynetworks:- add the list of valid and trusted remote SMTP servers. This option should include only local network IP addresses or networks separated by commas or whitespaces. Adding local network addresses avoids unauthorized access to mail servers.
- Uncomment the inet_interfaces = all line. This option allows Postfix to be accessible from the internet. With its default configuration, it will only receive emails from the local machine.
- Comment the inet_interfaces = localhost line. This option allows Postfix to be accessible from the internet. With its default configuration, it will only receive emails from the local machine.
Restart the postfix service.
# systemctl reload postfix
To verify an email communication between local users on the system
# echo "This is a test message" | mail -s <SUBJECT> <firstname.lastname@example.org>
Press Ctrl+D to send the message.
To verify the open relay is not active on your new mail server, send an email from your mail server to a domain that your new mail server doesn’t accept mail:
hello mydomain.com mail from: email@example.com rcpt to: firstname.lastname@example.org 554 Relay access denied - the server is not going to relay. 250 OK or similar- the server is going to relay. The 'rcpt to' option should only accept mail addressed to addresses @mydomain.com
In case of errors, check the