Howto: Configure Exim as SMTP Relay
An SMTP relay configuration is frequently employed in enterprise environments, allowing organizations to maintain control over their email communications and ensure reliable delivery through a central mail service infrastructure.
Exim1 is a Mail Transfer Agent (MTA) that facilitates the sending and receiving of email messages. In the following configuration, Exim is set up as a simple relay, forwarding messages to a central mail service. In this role, Exim serves as an intermediary in the email delivery process, relaying messages to a so called smart host.
Installation
The Fedora project provides Exim RPM packages in EPEL:
# make the EPEL repository available
dnf install -y epel-release
# install Exim and show version information 
dnf install -y exim
# install a mail client for testing
dnf install -y s-nailConfiguration
Exim uses a single configuration2 file /etc/exim/exim.conf.
# backup the main configuration file
cp /etc/exim/exim.conf /etc/exim/exim.conf.backup
# modify the Exim configuration...
$EDITOR /etc/exim/exim.conf ; exim -bV
# ...verify the configuration file is syntactically correct
# restart the service after configuration changes
systemctl restart exim.serviceAfter modifications to this file use exim -bV to run a syntax check. The configuration file contains a dedicated section about a smart host configuration:
# note following section in the default configuration
>>> grep 'smarthost:' -A4 /etc/exim/exim.conf 
smarthost:
  driver = manualroute
  domains = ! +local_domains
  transport = smarthost_smtp
  route_data = ROUTER_SMARTHOSTConfigure the ROUTER_SMARTHOST macro by providing the name of the local SMTP server that accepts to route email messages:
# alternative to editing the file manually
sed -i "s/^# ROUTER_SMARTHOST=.*/ROUTER_SMARTHOST=$mail_server/g" /etc/exim/exim.confUsage
exim -bt runs the address testing mode using a recipient address. Once the SMTP relay configuration is confirmed, send a mail to verify the functionality:
# how exim will route a given address
exim -bt $mail_address
# send a mail
echo "body" | mail -s "subject" -r root@$(hostname -f) $mail_addressSome operational commands for Exim:
# what is exim doing ...count of the messages in the queue
exiwhat
exim -bpc
# print configuration setting
exim -bP
# listing of the messages in the queue
exim -bp
exim -bp | exiqsummFootnotes
- Exim Internet Mailer 
 https://www.exim.org
 https://github.com/Exim/exim↩︎
- Exim Configuration File Documentation 
 https://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_exim_runtime_configuration_file.html↩︎