views:

821

answers:

4

I've got a stock Debian Etch system, using Exim4. The domains are mostly local but there are some that are remote. To handle the delivery of remote mail I use the Debian configuration file:

  /etc/exim4/hubbed_hosts

This file lists the domain names, and remote MX machines to deliver to. For example:

  example.org:  mx.example.com
  example.com:  mx2.example.com

Looking at the exim4 configuration file I see that this used as follows:

hubbed_hosts:
  debug_print = "R: hubbed_hosts for $domain"
  driver = manualroute
  domains = "${if exists{CONFDIR/hubbed_hosts}\
                   {partial-lsearch;CONFDIR/hubbed_hosts}\
              fail}"
  route_data = ${lookup{$domain}partial-lsearch{CONFDIR/hubbed_hosts}}
  transport = remote_smtp

The issue I have is that some of the hosts I'm using need to have their mail delivered to a non-standard port. Unfortunately the Debian hubbed_hosts file doesn't work if I try to change it to include a port:

example.org: mx1.example.org:2525
example.com: 1.2.3.4.2525

Is it possible to dynamically allow the port to be specified?

+1  A: 

make a new transport that specifies the port

remote_hub_2525:
driver = smtp
port = 2525

and then create a router for the domains needing non-standard delivery

non_standard_hub:
driver = manualroute
domains = example.org : example.com
transport = remote_hub_2525
no_more
manicmethod
Thanks for your help - I managed to get this to work in a more dynamic fashion as I wanted in the end.
Steve Kemp
+2  A: 

I was hoping for something a little more dynamic - and this solution works:

 port = ${if exists{/etc/exim4/ports.list}\
              {${lookup{$domain}lsearch{/etc/exim4/ports.list}\
              {$value}{25}}}{25}}

Then a simple file may have a list of ports on a per-domain basis:

   example.org: 2525
   example.com: 26
Steve Kemp
+2  A: 

You could probably use the ${extract} operator to let you combine the port numbers and host names, like in the example in your original question.

Something like (untested):

route_data = ${extract{1}{:}{${lookup{$domain}partial-lsearch{CONFDIR/hubbed_hosts}}}}
Mark Baker
+2  A: 

This is actually supported by default without any changes to your exim4 config.

In hubbed_hosts, you separate hosts with a colon, and you specify a port number with a double-colon. EX:

domain1: server1:server2::port:server3
domain2: server1::port
domain3: server1:server2

For more info check out http://www.exim.org/exim-html-current/doc/html/spec_html/ch20.html#SECID122

sherbang