How can I set up sendmail to forward all mail to an external MTA?

We have multiple applications that currently talk SMTP to an external MTA. The emails have arbitrary destination domains (they're emails to be sent to our users), but all from the same internal domain ([email protected]).

I want to set up an internal MTA (i guess with sendmail) that queues all mails, and have the internal MTA forward these emails to the external MTA, because the external MTA occasionally goes down and this causes various problems in our applications. I figure I can set up sendmail as a queuing middleware.

If the above assumptions are correct, what would the sendmail configuration look like? The 'mailertable' feature looks promising, and so does 'SMART_HOST'.

Any thoughts before I explore these possibilities?

  • Jae

Solution 1:

SMART_HOST is indeed the right option, but as well nullclient is. Examples:

FEATURE(`nullclient',`mta.external.com') dnl
define(`SMART_HOST',`mta.external.com') dnl

The basic difference is that nullclient, contrary to SMART_HOST, also forwards messages for local users to the remote host. SMART_HOST forwards to the remote host only messages for non-local users. Also following options might prove useful in a situation similar to that described in the question: LOCAL_RELAY, MAIL_HUB, LUSER_RELAY

I have found a great explanation of these options here: http://docstore.mik.ua/orelly/other/Sendmail_3rd/1565928393_sendmail3-chp-4-sect-5.html

Also see this post sendmail foward local mail to relay host

I know the question is old, but seems suitable to post the information. It took me a while to collect all the bits together.

Solution 2:

Such a configuration (relaying all mail to a single other MTA) is called a 'nullclient' configuration. Some guides are available:

  • Postfix: http://www.postfix.org/STANDARD_CONFIGURATION_README.html#null_client
  • Sendmail: http://www.sendmail.org/m4/features.html

For sendmail, all you should need it:

FEATURE(`nullclient', `mailhub.domain.notused')dnl

Some distros (openSuSE) provide a separate 'nullclient.mc' configuration file for this purpose.

Solution 3:

The SMART_HOST parameter is exactly what you're looking for. Exact configuration details will depend on your sendmail version, but it's fairly straightforward. You'll specify the name of the external MTA as the smart host when you configure it. (Be sure that the machine you're configuring can resolve the name of the smart host, too.)