2

I have a SendMail server. I want traffic going to "special" domains to be redirected to a different location. I've done that by essentially considering some domains "local" and using some simple routing logic:

1) If sending to special domains (e.g. DOMAINA.com or DOMAINB.com) send to 1.1.1.1.

dnl # define mail_hub to special route
define(`MAIL_HUB',`relay:[1.1.1.1]')dnl

dnl # define list of 'local' domains that will be forwarded to the mail hub
define(`confCW_FILE',`/etc/mail-tls/special_domains')dnl

2) Else send to 2.2.2.2

define(`SMART_HOST',`relay:[2.2.2.2]')dnl

That seems to work great. But now I have a requirement to complicate the logic:

1) If sending to special domains (e.g. DOMAINA.com or DOMAINB.com) and envelope sender is NOT sending from [email protected], send to 1.1.1.1

2) Else send to 2.2.2.2

Is there an easy way to do this (without requiring a milter)?

1
  • It should be possible in sendmail.cf, but I've never had to do that in sendmail. In exim it's so easy that I'm tempted to submit an answer saying that that is the easiest solution. However I would like to note: 1) for your earlier destination-only problem, it would have been easier to use a mailertable 2) a milter is not that difficult, but I don't see relay control in the milter API. To change the relay you'd need to change the destination address and control the destination server to change it back.
    – Law29
    Jan 28, 2016 at 19:28

1 Answer 1

1

You may combine two sendmail.cf recipes:

1) MailertableRuleSets - it allows to select sendmail.cf custom rule-set for email routing via mailertable (custom routing by recipient domain)
Warning: It requires a few lines patch of one of files used to generate sendmail.cf

"Mailertable Rule Sets (sendmail)" by anfi (2004)

2) SmartTable - it shows how to route based on envelope sender address ($f)

"Smart Table (sendmail)" by anfi (1999,2002)


WARNING: sendmail keeps original sender address in $f when sending bounce messages
(AFAIR in "at once" delivery attempt).

3
  • Hi, what is the use case for MRS instead of plain standard mailertable? +1 for SmartTable, it seems like that is exactly what Mike B is looking for.
    – Law29
    Jan 29, 2016 at 8:33
  • 1
    Standard mailertable selects directly mailer&destination_host(s). MRS extension of (mainly) mailertable allows mailertable to select (based on recipient's domain) sendmail.cf rule-set responsible for setting delivery path. As I understand Mike wanted "smarttable for SOME destinations".
    – AnFi
    Jan 29, 2016 at 9:43
  • OK, SmartTable is the custom rule-set in the MRS description, so: MRS to select the destinations (domaina.com and domainb.com) to use SmartTable on, and SmartTable to route mail according to source. BTW you might be the one to help me with serverfault.com/questions/734919/…
    – Law29
    Jan 29, 2016 at 10:22

You must log in to answer this question.

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