2

Im administering a bunch of development and staging debian (v.6-8) servers. The current exim4 setup looks like this:

  • There are no incoming mails on the servers (no wan connection)
  • Outgoing mails are send via a smarthost (this is currently working)

Since the stage and dev servers email functionality will be tested through web apps and there are real world scenario email addresses set up in our web applications, The setup that I want to achive is:

  • All outgoing mails should be forwarded by a catchall statement to one single email address, for example devmail@1234oursmarthost.com
  • All outgoing mails, that contain our companies domains, like *@example.com and *@foo.com should bypass the catchall rule.

The tutorial, that is closest to my goal is this, even if it uses the opposite strategy: Allow all senders and deny one sender.

https://serverfault.com/a/577007/322673

Any help is really appreciated, since I'm going to be nuts on exim config syntax.

I'd been through a whole lot a configuration samples for days now, but none of them are matching my use case.

2

As Exim processes mail in the order specified in the routers section, I guess it can be achieved with the following rules. Be sure to put rule for the special domains first and then the catch all rules.

# sender domain based routing
router_for_special_domain_sender:
     driver = dnslookup
     senders =  *@example.com 
     transport = remote_smtp
     no_more 

# reciepients domain based routing
router_for_special_domain_reciepints:
     driver = dnslookup
     domains =  example.com 
     transport = remote_smtp
     no_more 

catch_all_outgoing:
     driver = redirect
     data = catchallemail@example.com

According to Exim documentation:

domains

If the domains option is set, the domain of the address must be in the set of domains that it defines.

senders

If this option is set, the router is skipped unless the message’s sender address matches something on the list. See section 3.12 for a list of the order in which preconditions are evaluated.

The first rule above tells exim to send all emails with a sender domain example.com to be sent without doing anything special. The second rule is a catch all for all emails. You can give it a try.

Here is the relevant discussion: http://www.gossamer-threads.com/lists/exim/users/97056

6
  • Heya @bangal, thanks for your reply. The config you provided doesnt let the *.example.com pass through the catch_all_outgoing rule. I should have said, that *@example.com domains are recipients, not senders. In other words. All *@example.com mails should be delivered to example.com recipients, all others forwarded to the devmail@1234.oursmarthost.com account. – Server Admin Nov 24 '15 at 11:35
  • I have updated my answer. Have a look. – Diamond Nov 24 '15 at 11:42
  • Hi @bangal: Exim responds with option "domain" unknown when restarting. – Server Admin Nov 24 '15 at 12:29
  • Sorry typo, use domains. – Diamond Nov 24 '15 at 12:37
  • The config above ended up with a "Connection timed out" message on the dev server side. Thank you so much for all the time you invested. I finally got it made through your help. – Server Admin Nov 24 '15 at 14:18
0

begin routers

 router_for_special_domain_reciepint:
 driver = manualroute
 domains =  example.com
 transport = remote_smtp
 route_list = "* internalsmarthost.example.com "
 no_more

catch_all_outgoing: driver = redirect data = devmail@1234oursmarthost.com

Since Im using a smarthost for both, the exception in the router_for_special_domain_recipient router and for the catch_all_outgoing router, I had to add the route_list option. Using the dnslookup driver would have the consequence of sending the mail directly to the target without the use of a smarthost.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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