If your company is behind a strict firewall or you want to forward all mail through a trusted SMTP server (your ISP’s for example), you’ll want to setup sendmail to perform “smart relaying”. This allows you to setup a box that will do spam filtering, AV scanning, etc. without having to reconfigure your primary mail server. I stumbled across this when we were running into issues sending mail from a PHP script using local sendmail on a machine without reverse DNS and behind a strict firewall.
Setting up smart relaying is actually fairly simple assuming that you already have sendmail installed and configured to accept mail from your domain(s). We simply have to edit/add one line in the sendmail.mc file (located in /etc/mail on CentOS and most other distros):
Make sure that you replace my.mailhost.tld with the hostname of the mail server that you want to relay mail to (ex. smtp.myisp.com). Your configuration file may already have this line, just be sure that it doesn’t have dnl in front of it like this:
dnl define(`SMART_HOST', `my.mailhost.tld')dnl
Once you have completed this change, the sendmail.cf file needs to be rewritten:
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf /etc/init.d/sendmail restart
Et voila! Your sendmail server should now be relaying mail. If you run into any issues sending mail, you may want to make sure that the server being relayed to accepts relaying from your server’s IP without authentication.