Configuring sendmail as a multi-domain relay server

11,616

We do exactly this.

You need to make entries in two configuration files.

First, enter the domains you are going to relay for in /etc/mail/relay-domains, one per line. Include any variations.

Second, in /etc/mail/mailertable, you have to tell sendmail what to do with mail destined for that domain.

Example:

/etc/mail/relay-domains:

exampledomain.com
otherdomain.com

/etc/mail/mailertable:

exampledomain.com    relay:mailboxes.exampledomain.com

Remember to run make in /etc/mail so that the changes to mailertable take effect.

Note that if you don't put an entry in mailertable for a domain, it will consult DNS and try to send to a 'better' MX; if DNS has nothing of use, it will try to deliver the mail locally (and fail, unless you've doctored /etc/mail/local-host-names).

Share:
11,616

Related videos on Youtube

Brian Cline
Author by

Brian Cline

Updated on September 17, 2022

Comments

  • Brian Cline
    Brian Cline almost 2 years

    I've got several different servers running different OS's internally and each handles e-mail for specific domains. Since I only have one public-facing IP for these, I'd like to configure my CentOS-based server in such a way that it only accepts incoming messages for specific domains from the outside world, and subsequently relays those messages to the proper internal server based on the recipient domain.

    I do not want to hack up DNS to accomplish this. I know I could simply create zones on the CentOS server with MX entries that point to the proper internal addresses, but that's a bit of a kludge. I need that machine to continue using the publicly available versions of each domain's zones, so this is not an option. As a side note, all the proper MX entries already point to my public-facing IP address.

    I've read a little on smart tables and it seems that only the sender's domain is inspected. I may be wrong on this so have not ruled it out.

    Is such a solution possible with Sendmail? If so, what configuration options and features will allow me to do this? Samples would be much appreciated.

  • Brian Cline
    Brian Cline over 14 years
    Thanks. This seems to work fairly well, but only for the domains that I have separate internal DNS zones for (needed since those are maintained by Active Directory; they have internal MX records as well, which appears to be why the relay works for them). For the other domains, it is still looking up public DNS and returning an error stating "mail loops back to me (MX problem?)". If I understand this solution correctly, my relay-domains file is being checked but the mailertable doesn't seem to be. Is there another setting I need to tinker with to get it to pay attention to mailertable?
  • David Mackintosh
    David Mackintosh over 14 years
    Make sure you have the "mailertable" feature in your sendmail.mc file. Also make sure that you run "make" in /etc/mail. The mailertable is a hash file, it isn't read out of the text file the way that some other options are. On my system, I see that the file 'mailertable.db' is newer than the file 'mailertable', that's how I know the make worked. Alternatively you might try using the directive "smpt:" instead of "relay:" in the mailertable file.
  • David Mackintosh
    David Mackintosh over 14 years
    ...err, that's "smtp:", not "smpt:".
  • Brian Cline
    Brian Cline over 14 years
    Yes, I am performing a make after each change to the mailertable. I've also ensured that the mailertable feature is defined and not commented out in my sendmail.mc file, and I've performed a make after my modifications to it as well. The feature line for it shows up in the resulting .cf file as well. Unfortunately, sendmail is still disregarding the mailertable.
  • Brian Cline
    Brian Cline over 14 years
    Since this has evolved into a separate issue of sendmail not referring to mailertable as instructed, I've marked this as the answer and started a separate question here: serverfault.com/questions/94481/…