Specify remote port to use for mail routing via hubbed_hosts with exim4



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:


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:

  debug_print = "R: hubbed_hosts for $domain"
  driver = manualroute
  domains = "${if exists{CONFDIR/hubbed_hosts}\
  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

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




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


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

 port = ${if exists{/etc/exim4/ports.list}\

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

   example.org: 2525
   example.com: 26