Configuring sendmail as a multi-domain relay server

emailemail-serversendmail

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.

Best Answer

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).

Related Topic