Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Asked this on StackOverflow ( but someone pointed out it belongs here.

I am trying to use exim4 on debian to relay mail, nothing more. I have a stage mail server and a production mail server (both written custom in python to do weird stuff). I also have all these running on a single linode host.

production mail is on port 2500, stage mail is running on port 2501. I'd like exim to relay mail based on the target domain to these nonstandard ports. I can easily get it to recognize the domain, but I can't seem to find any info on how to add port information to the configuration.

share|improve this question
up vote 3 down vote accepted

In the remote_smtp transport, add:

  port = ${lookup{$sender_address_domain}lsearch{/etc/exim/domain_port_mapping}{$value}{25}}

And then put your domain to port mappings into /etc/exim/domain_port_mapping as a regular lsearch list:    2500    2501
share|improve this answer
Thanks. I'm still getting unroutable address in the logs. Do I need any special configuration for the relay? – dave paola Nov 2 '09 at 18:45
That is the special configuration for the "relay" -- as in, the machine that receives mail on the regular port and then forwards to the alternate port. That config worked for me when I needed to do this. Now, of course, I just run Postfix and use a transport map, no special configuration required. – womble Nov 2 '09 at 19:23
Just a note: $sender_address_domain is just $domain. Not sure if this is an exim4-specific thing, but took me quite awhile to figure out that's why it wasn't working :-) – dave paola Nov 3 '09 at 7:31
Aaah, target domain. Misread. – womble Nov 3 '09 at 9:18

Your Answer


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.