How To Configure sendmail’s Smart Relay Host

To configure a Solaris server’s smart relay host, most people will simply edit the DS entry in /etc/mail/sendmail.cf and leave it at that. Let’s assume that smtp is the name of the smart relay host. By adding the string ‘smtp$?m.$m$.’ in sendmail.cf – ‘$?m.$m$.’ is sendmail’s way of representing the server’s domain name – and after restarting the sendmail daemon, e-mails will get relayed to the host smtp. The problem with this approach is if somebody came along and did things the “right” way, all changes that were made directly to sendmail.cf will be wiped away.

:
:{snip}
:
# "Smart" relay host (may be null)
DSsmtp$?m.$m$.
:
:{snip}
:

A Solaris admin worth the name will never do the above. sendmail.cf is the compiled output of another file which by convention can be found in /etc/mail/cf/cf. Initially, this file is named sendmail.mc. But the first thing a good Solaris admin will do is to make a copy of the file and call it <hostname>.mc, where hostname is the output of the command /usr/bin/hostname.

# cd /etc/mail/cf/cf
# cp -p sendmail.mc `hostname`.mc

Now, edit <hostname>.mc and add this line.

define(`SMART_HOST', `smtp$?m.$m$.')

Replace the string ‘smtp’ with the name of the server that relays e-mails; i.e. the smart relay host, in your organisation.

Save the file and compile it.

# /usr/ccs/bin/make `hostname`.cf
test ! -f solaris-srv.cf || /usr/bin/mv solaris-srv.cf solaris-srv.cf.prev
/usr/ccs/bin/m4 ../m4/cf.m4 solaris-srv.mc > solaris-srv.cf
# ls -l `hostname`.cf
-rw-r--r--   1 root     root       40283 Oct 31 11:14 solaris-srv.cf
#

Copy the <hostname>.cf file over /etc/mail/sendmail.cf and restart the sendmail daemon.

# cp solaris-srv.cf /etc/mail/sendmail.cf
# svcadm restart svc:/network/smtp:sendmail
# svcs /network/smtp:sendmail
STATE          STIME    FMRI
online         11:30:20 svc:/network/smtp:sendmail
#