Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

4 Answers 4

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.

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

The above rule should be added to your /etc/mail/sendmail.mc. Next you should build your sendmail.cf 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

Have a look at RoutebySender software utility.

share|improve this answer
1  
Welcome to Server Fault! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. –  slm Aug 21 '13 at 12:50

Your Answer

 
discard

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.