How to configure a Sendmail Smart Host
Environment
- Red Hat Enterprise Linux 3
- Red Hat Enterprise Linux 4
- Red Hat Enterprise Linux 5
- Red Hat Enterprise Linux 6
- Red Hat Enterprise Linux 7
- Sendmail
Issue
- How to configure a Sendmail smart host
- How to forward all emails destined for remote recipients to a centralized mail server
- How to configure a relay host in Sendmail
Resolution
To configure a Sendmail Smart Host, follow these steps:
-
The /etc/mail/sendmail.mc file contains the following line:
dnl define(`SMART_HOST',`smtp.your.provider')dnlRemove
dnl("delete through newline") from the beginning of the line :define(`SMART_HOST',`smtp.your.provider') dnl -
Now substitute
smtp.your.providerwith the address of the SMTP relay server. There are four possible formats:-
hostname- If MX record is present, it is used, otherwise DNS is looked up normally.For example:
define(`SMART_HOST',`redhat.com') -
[hostname]- DNS is looked up normally, MX record is ignored. Use this if the MX record is different from the hostname, and you do not want to use it.For example:
define(`SMART_HOST',`[redhat.com]') -
[IPv4 address]- The provided IPv4 address is used.For example:
define(`SMART_HOST',`[192.0.2.4]') -
[IPv6 address]- The provided IPv6 address is used.For example:
define(`SMART_HOST',`[IPv6:2002:c0a8:51d2::23f4]')Note: if the sendmail system does not have a working DNS functionality, please see: Can sendmail be used without DNS?.
-
-
Install the sendmail-cf package:
# yum install sendmail-cf -
Generate a new sendmail.cf file. This happens automatically once the sendmail-cf package is installed. Note that any custom changes to sendmail.cf are lost in the process, so take a backup if necessary.
For RHEL 6 and earlier:
# service sendmail restartFor RHEL 7 and later:
# systemctl restart sendmail
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.