Search code examples
smtpdebianlinodeexim

exim4 nonstandard ports


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.


Solution

  • You should create 2 routers and 2 transports, below configuration could work.

    domain_list my_relay_2500 = example1.com:example2.com
    domain_list my_relay_2501 = example3.com:example4.com
    
    my_relay_2500_router:
     driver = manualroute
     domains = +my_relay_2500
     transport = my_remote_smtp_2500
     route_data = ${lookup{$domain}lsearch{/etc/exim/remote_relay.txt}}
     no_more
    
    # after `begin transports`
    my_remote_smtp_2500:
      driver: smtp
      port: 2500
    
    my_remote_smtp_2501:
      driver: smtp
      port: 2501
    

    File /etc/exim/remote_relay.txt

    example1.com: 10.0.0.3   my_remote_smtp_2500
    example2.com: 10.0.0.3   my_remote_smtp_2500
    example3.com: 10.0.0.3   my_remote_smtp_2501
    example4.com: 10.0.0.3   my_remote_smtp_2501