Setup Sendmail Smart Relay in FreeBSD

It’s good that to route all your outgoing email to a relay server for centralize management. Compiling Sendmail’s Smart Relay options in FreeBSD is slightly different from Linux machine. But it’s fairly easy to do so. Just follow the steps below, and I assume you already have your own email relay server to relay to.

Go to /etc/mail
run “make” command for the first time to generate “yourdomain”.cf and “yourdomain” / “yourdomain”.mc and “yourdomain” file

shell> cd /etc/mail
shell> make
shell> cp "yourhostname".mc
/usr/bin/m4 -D_CF_DIR_=/usr/share/sendmail/cf/   /usr/share/sendmail/cf/m4/cf.m4 "yourhostname".mc > "yourhostname".cf
cp "yourhostname"
/usr/bin/m4 -D_CF_DIR_=/usr/share/sendmail/cf/   /usr/share/sendmail/cf/m4/cf.m4 "yourhostname" > "yourhostname"

After mc and mf files have generated. Edit .mc file, look for line below. Change the SMART HOST to your email server’s hostname. It must be hostname and you CAN’T configure IP Address for SMART HOST.

shell> vi "yourdomain".mc

dnl define(`SMART_HOST', `your.isp.mail.server')
define(`SMART_HOST', `relay.server.hostname')

Next copy “define(`SMART_HOST’, `relay.server.hostname’)” and paste it in “yourhostname” It must be placed before the line of “msp” feature.

define(`SMART_HOST', `relay.server.hostname')
FEATURE(`msp', `[]')dnl

After configuration has been made, now run "make install" to generate the cf file and replace and

shell> make install
shell> /usr/bin/m4 -D_CF_DIR_=/usr/share/sendmail/cf/   /usr/share/sendmail/cf/m4/cf.m4 "yourhostname".mc >  "yourhostname".cf
install -m 444  "yourhostname".cf /etc/mail/
/usr/bin/m4 -D_CF_DIR_=/usr/share/sendmail/cf/   /usr/share/sendmail/cf/m4/cf.m4  "yourhostname" >  "yourhostname"
install -m 444 /etc/mail/

You are basically done, now. Just restart sendmail services.

shell> /etc/rc.d/sendmail restart
shell> Cannot 'restart' sendmail. Set sendmail_enable to YES in /etc/rc.conf or use 'onerestart' instead of 'restart'.
Stopping sendmail_submit.
Waiting for PIDS: 64903.

Ignore the line to change sendmail_enable to YES if your server just do email submit and it doesn't act as incoming email.