How to configure conditional smart relay with sendmail on Rocky Linux 8

Sendmail

Rocky Linux 8 with sendmail hosting multiple domains works fine. Only one domain should be configured to use a smarthost with a third party anti-spam service. We want to prevent that every e-mail will be relayed to one external smart host, all other e-mails should go out directly.

  1. Create a smarttable file.
    # touch /etc/mail/smarttable
  2. Download smarttable.m4 and copy the file to /usr/share/sendmail-cf/feature/
    # cd /usr/share/sendmail-cf/feature/
    # wget http://jmaimon.com/sendmail/anfi.homeunix.net/sendmail/smarttable.m4
  3. Add following entry to your sendmail.cf file.
    FEATURE(`smarttable')dnl
  4. Rebuild the sendmail config
    # /etc/mail/make
    # service sendmail restart
  5. Create your smarttable
    # cat /etc/mail/smarttable
    @domain-a.com relay-cluster-eu01.hornetsecurity.com
    @domain-b.com relay-cluster-us01.hornetsecurity.com
  6. Rebuild smartable by using makemap
    # makemap hash /etc/mail/smarttable < /etc/mail/smarttable

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.