Sendmail is a popular Mail Transfer Agent (MTA) and it is the default MTA on Red hat Linux Enterprise (RHEL). Typically, within enterprises, you will need a Mail User Agent (MUA), an MTA and an SMTP Relay to send emails (outbound) from the Linux command-line or shell scripts.

So, let’s assume that your Mail Administrator provides you IP addresses of primary ( and secondary ( SMTP Relay hosts. Given below are steps to configure sendmail (on RHEL 4) to use the SMTP relays to send email (you must use root user’s privileges):

STEP 1: Verify sendmail packages

In order to configure sendmail, you will require the sendmail and sendmail-cf packages. Given below is an example of how to check for these packages:

rpm -qa | grep sendmail


STEP 2: Modify

Do not edit /etc/mail/ Instead, you must edit /etc/mail/ (more readable than and use the m4 macro processor to generate

Edit /etc/mail/ and add the following line:



(1) Pay attention to the quotes. Do not prefix the above by the letters dnl as dnl (delete to new line) denotes a comment in

(2) If you wish to configure only 1 SMTP relay host (e.g., then add the following:


STEP 3: Start/Restart sendmail

When sendmail is started (if not running) or restarted (if running), then the file will be processed by the m4 macro processor and a corresponding will be generated. On RHEL, you may start sendmail as follows:

/sbin/service sendmail start

STEP 4: Use an MUA to test outbound mail

In order to test your sendmail configuration and the SMTP relays, use an MUA to send emails. Given below is an example that uses mutt to send emails:

mutt -s "test email" < /dev/null
VN:F [1.9.22_1171]
Rating: +27 (from 33 votes)