Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm handling email for many different companies. Each company needs me to route all outbound email through a specific SMTP relay based on From address.

What software configuration or technology allows me to do this?

We are a Windows shop with Exchange 2010, but are open to other options like sendmail, or even buying or finding someone to build a custom Transport Agent

share|improve this question

Assuming your Exchange machine forwards all email to another that runs sendmail, you can decide to route based on sender domain by using the $&f macro in rule set 0.

# first make sure that local mail gets delivered properly
R$-        $@OK
R$* < @ $=w . > $*        $@OK
# now deal with senders
R$*        $: $>canonify $&f $| $1
# stuff sends goes through server1.relay
Ruser1 < @ > $* $| $* < @ $* . > $*         $#esmtp $@ [server1.relay] $: $2 < @ $3 . > $4
# stuff sends goes through server2.relay
Ruser2 < @ > $* $| $* < @ $* . > $*         $#esmtp $@ [server2.relay] $: $2 < @ $3 . > $4
# stuff users from send goes through server3.relay
R$* < @ > $* $| $* < @ $* . > $*        $#esmtp $@ [server3.relay] $: $3 < @ $4 . > $5

The above rule should be added to your /etc/mail/ Next you should build your and restart sendmail. Assuming you are on a Debian or Ubuntu system, this is done by issuing sendmailconfig. Keep in mind that in the above example the left and right hand sides of the rules are separated by tabs and not spaces, so you must type and not copy-paste the rule set.

share|improve this answer

Well, I'm biased towards (and familiar with) Linux with Postfix for front-line MTA work, so here's a solution with that:

Sender-dependent transport maps

   domain transport:nexthop
          Deliver  mail  for domain through transport to next-hop.
share|improve this answer

If you want to do this with Linux/sendmail, I think you'd need to setup a smart table. Details are available here.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.