6

I'm trying to setup an email server so it has the capability to send email from multiple IP addresses, so our marketing system can send email from multiple domains, while keeping the reverse DNS lookups consistent. IE, domain1.com resolves to 10.0.0.1, domain2.com resolves to 10.0.0.2, etc.

Ideally, the mail server would check the from domain in the headers, then choose the correct IP address from a pool, using that for the actual sending. Right now, we're using Exim, and I was thinking that one solution would be to run multiple instances of Exim on different interfaces, then write an SMTP proxy that would do the header checking and forward the email to the correct Exim instance, but I'm thinking there may be a simpler solution than that.

Just so everyone knows, this doesn't involve spamming, and we own all the domains and IP addresses we would be using.

3 Answers 3

8

If I understand you, you have the mail on a server, and that server has, say, 4 IP addresses configured on it. You would like you mail server, when sending to the internet, to use one of those four IPs as the outbound interface. If this is the wrong interpretation, please let me know.

The Exim SMTP transport can be configured to send email via different interfaces. In a hard coded manner you could do this:

routers:

send_domaina_com:
  driver = dnslookup
  domains = domaina.com
  transport = domaina_com_smtp

send_domainb_com:
  driver = dnslookup
  domains = domainb.com
  transport = domainb_com_smtp

send_domainc_com:
  driver = dnslookup
  domains = domainc.com
  transport = domainc_com_smtp

send_domaind_com:
  driver = dnslookup
  domains = domaind.com
  transport = domaind_com_smtp

TRANSPORTS:

domaina_com_smtp:
  driver = smtp
  interface = 10.0.0.1

domainb_com_smtp:
  driver = smtp
  interface = 10.0.0.2

domainc_com_smtp:
  driver = smtp
  interface = 10.0.0.3

domaind_com_smtp:
  driver = smtp
  interface = 10.0.0.4

I'm 99.99% the above will work, though it's obviously ugly. I think everything you need it to be handled dynamically is there ("interface" is expandable).

0

To maintain route integrity, I'm thinking you would have to bind different instances of exim to different interfaces (as you say)

the proxy isn't really required, you can simply use a router (per domain/from: match) with a condition set to dictate which 'host' to relay through.

never tried this. would be interested to know if it works..

0

Exim can send e-mails from different IP-addresses based on domain name in the "From:" header. There is no need to hard code each domain individually. An interface for remote_smtp transport should be set as follows:

interface = "${lookup{${lc:${domain:${address:$h_from:}}}}lsearch{/etc/exim/domainips}{$value}}"

A list of domain-IP pairs /etc/exim/domainips needs to be created in the following format:

domain1.com: 10.0.0.1
domain2.com: 10.0.0.2

Also, if PTR record for 10.0.0.1 is pointing to domain1.com, then it would be nice to set HELO accordingly:

helo_data = ${lc:${domain:${address:$h_from:}}}

If e-mails are sent by PHP/Apache, then the actual envelope sender will always be same regardless of the "From:" header (e.g. apache@primary_hostname.com). In order to fix this, return_path may be set:

return_path = ${address:$h_from:}

Ideally, remote_smtp transport will look like this:

remote_smtp:
driver = smtp
interface = "${lookup{${lc:${domain:${address:$h_from:}}}}lsearch{/etc/exim/domainips}{$value}}"
helo_data = ${lc:${domain:${address:$h_from:}}}
return_path = ${address:$h_from:}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .