Discussion:
Equivalent to transport_maps from Postfix in Exim
Patric Falinder
2012-12-10 09:41:52 UTC
Permalink
Hi,

I've been using Postfix for many years and I've recently migrated some of
my servers to Exim.
In Postfix I've been using transport_maps to specify where a specific
domain or email-address should go.

In some cases I have a couple of users that are not on the same server as
the rest of the domain. So I've done something like this:

domain.com smtp:[mail.domain.com]
***@domain.com smtp:[other.server.domain.com]


How would I achieve this in Exim?
I haven't done any actual configuration on this Exim-server myself so I
don't really know where to look.


Thanks,
-Patric
--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
John Burnham
2012-12-10 11:39:38 UTC
Permalink
Post by Patric Falinder
I've been using Postfix for many years and I've recently migrated some of
my servers to Exim.
In Postfix I've been using transport_maps to specify where a specific
domain or email-address should go.
In some cases I have a couple of users that are not on the same server as
domain.com smtp:[mail.domain.com]
How would I achieve this in Exim?
I haven't done any actual configuration on this Exim-server myself so I
don't really know where to look.
You mean you want to pass the mail on to another SMTP server ? In that case, what you're probably looking for is the manualroute router. It is documented at

http://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_manualroute_router.html

which has some reasonable examples.

For your above example you could have something like:

test_route:
driver = manualroute
domains = domain.com
local_parts = !user1
transport = remote_smtp
route_list = domain.com mail.domain.com

test_route2:
driver = manualroute
domains = domain.com
local_parts = user1
transport = remote_smtp
route_list = domain.com other.server.domain.com

in your routers. Remember that routers are traversed in the order they're encountered in your config file.

You can, of course, use lookups or files to make it more general. (local_parts = dbm; /etc/exim/$domain/list.of.local.parts). Some of this is clarified in

http://www.exim.org/exim-html-current/doc/html/spec_html/ch-generic_options_for_routers.html

Have a look at the docs and if you want any clarification, please ask.

John
--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Patric Falinder
2012-12-10 12:03:07 UTC
Permalink
Post by John Burnham
Post by Patric Falinder
I've been using Postfix for many years and I've recently migrated some of
my servers to Exim.
In Postfix I've been using transport_maps to specify where a specific
domain or email-address should go.
In some cases I have a couple of users that are not on the same server as
domain.com smtp:[mail.domain.com]
How would I achieve this in Exim?
I haven't done any actual configuration on this Exim-server myself so I
don't really know where to look.
You mean you want to pass the mail on to another SMTP server ? In that
case, what you're probably looking for is the manualroute router. It is
documented at
http://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_manualroute_router.html
which has some reasonable examples.
driver = manualroute
domains = domain.com
local_parts = !user1
transport = remote_smtp
route_list = domain.com mail.domain.com
driver = manualroute
domains = domain.com
local_parts = user1
transport = remote_smtp
route_list = domain.com other.server.domain.com
in your routers. Remember that routers are traversed in the order they're
encountered in your config file.
You can, of course, use lookups or files to make it more general.
(local_parts = dbm; /etc/exim/$domain/list.of.local.parts). Some of this is
clarified in
http://www.exim.org/exim-html-current/doc/html/spec_html/ch-generic_options_for_routers.html
Have a look at the docs and if you want any clarification, please ask.
Thanks for the reply. I found this where it looks in a file where I have
specified the transport for each domain, I'm wondering if it's possible to
add a second file to this, 'emailaddress.list' for example, where I will
specify which route a specific email-address should take if it's not going
to the standard server.

filter_forward:
driver = manualroute
transport = remote_smtp
domains = !@ : +relay_to_domains
route_data =
${lookup{$domain}wildlsearch{VARDIR/spool/tmp/mailcleaner/domains.list}}
hosts_randomize = true
headers_remove = X-MailCleaner-Bounce
headers_add = X-MailCleaner-ReportURL: __REPORT_URL__



For example, it it possible to do something like this:

filter_forward:
driver = manualroute
transport = remote_smtp
domains = !@ : +relay_to_domains
route_data =
${lookup{$domain}wildlsearch{VARDIR/spool/tmp/mailcleaner/domains.list}}${lookup{$domain}wildlsearch{VARDIR/spool/tmp/mailcleaner/emailaddress.list}}
hosts_randomize = true
headers_remove = X-MailCleaner-Bounce
headers_add = X-MailCleaner-ReportURL: __REPORT_URL__


Thanks,
-Patric
--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
John Burnham
2012-12-10 12:31:27 UTC
Permalink
Post by John Burnham
driver = manualroute
transport = remote_smtp
route_data =
${lookup{$domain}wildlsearch{VARDIR/spool/tmp/mailcleaner/domains.list}
}${lookup{$domain}wildlsearch{VARDIR/spool/tmp/mailcleaner/emailaddres
s.list}}
hosts_randomize = true
headers_remove = X-MailCleaner-Bounce
headers_add = X-MailCleaner-ReportURL: __REPORT_URL__
Hmm. Not quite - for a start $domain is the domain, so looking it up against a list of email addresses won't work (wildlsearch{VARDIR/spool/tmp/mailcleaner/emailaddress.list}). If you can cope with having emails listed in your file - with *@domain meaning all mail at that domain then something like:


test_router:
driver = manualroute
transport = remote_smtp
domains = ! +local_domains
route_data = ${lookup{$local_part@$domain}wildlsearch{/etc/exim/jpb15}}

(The hosts_randomize and headers stuff you can keep - it doesn't affect the routing though so I'll leave them out).


and a file like /etc/exim/jpb15 contains:

*@admin.cam.ac.uk: uasmailhost.internal.admin.cam.ac.uk
***@cam.ac.uk: mailhost.internal.admin.cam.ac.uk
***@gmail.com: uasmailhost.internal.admin.cam.ac.uk
*@gmail.com: mailhost.internal.admin.cam.ac.uk
*: defaultmail.admin.cam.ac.uk


I can then do some tests with exim -bt:
routing ***@cam.ac.uk
--------> test_router router <--------
local_part=jpb15 domain=cam.ac.uk
checking domains
cam.ac.uk in "@ : localhost : localhost.localdomain"? no (end of list)
cam.ac.uk in "! +local_domains"? yes (end of list)
calling test_router router
test_router router called for ***@cam.ac.uk
domain = cam.ac.uk
search_open: wildlsearch "/etc/exim/jpb1"
search_find: file="/etc/exim/jpb1"
key="***@cam.ac.uk" partial=-1 affix=NULL starflags=0
LRU list:
F/etc/exim/jpb1
End
internal_search_find: file="/etc/exim/jpb1"
type=wildlsearch key="***@cam.ac.uk"
file lookup required for ***@cam.ac.uk
in /etc/exim/jpb1
***@cam.ac.uk in "*@admin.cam.ac.uk"? no (end of list)
***@cam.ac.uk in "***@cam.ac.uk"? yes (matched "***@cam.ac.uk")
lookup yielded: mailhost.internal.admin.cam.ac.uk
original list of hosts = "mailhost.internal.admin.cam.ac.uk" options =
expanded list of hosts = "mailhost.internal.admin.cam.ac.uk" options =
set transport remote_smtp
finding IP address for mailhost.internal.admin.cam.ac.uk


exim -d -bt ***@admin.cam.ac.uk
routing ***@admin.cam.ac.uk
--------> test_router router <--------
local_part=jpb15 domain=admin.cam.ac.uk
checking domains
admin.cam.ac.uk in "@ : localhost : localhost.localdomain"? no (end of list)
admin.cam.ac.uk in "! +local_domains"? yes (end of list)
calling test_router router
test_router router called for ***@admin.cam.ac.uk
domain = admin.cam.ac.uk
search_open: wildlsearch "/etc/exim/jpb1"
search_find: file="/etc/exim/jpb1"
key="***@admin.cam.ac.uk" partial=-1 affix=NULL starflags=0
LRU list:
F/etc/exim/jpb1
End
internal_search_find: file="/etc/exim/jpb1"
type=wildlsearch key="***@admin.cam.ac.uk"
file lookup required for ***@admin.cam.ac.uk
in /etc/exim/jpb1
***@admin.cam.ac.uk in "*@admin.cam.ac.uk"? yes (matched "*@admin.cam.ac.uk")
lookup yielded: uasmailhost.internal.admin.cam.ac.uk
original list of hosts = "uasmailhost.internal.admin.cam.ac.uk" options =
expanded list of hosts = "uasmailhost.internal.admin.cam.ac.uk" options =
set transport remote_smtp

exim -d -bt ***@gmail.com

routing ***@gmail.com
--------> test_router router <--------
local_part=foo domain=gmail.com
checking domains
gmail.com in "@ : localhost : localhost.localdomain"? no (end of list)
gmail.com in "! +local_domains"? yes (end of list)
calling test_router router
test_router router called for ***@gmail.com
domain = gmail.com
search_open: wildlsearch "/etc/exim/jpb1"
search_find: file="/etc/exim/jpb1"
key="***@gmail.com" partial=-1 affix=NULL starflags=0
LRU list:
F/etc/exim/jpb1
End
internal_search_find: file="/etc/exim/jpb1"
type=wildlsearch key="***@gmail.com"
file lookup required for ***@gmail.com
in /etc/exim/jpb1
***@gmail.com in "*@admin.cam.ac.uk"? no (end of list)
***@gmail.com in "***@cam.ac.uk"? no (end of list)
***@gmail.com in "***@gmail.com"? yes (matched "***@gmail.com")
lookup yielded: uasmailhost.internal.admin.cam.ac.uk
original list of hosts = "uasmailhost.internal.admin.cam.ac.uk" options =
expanded list of hosts = "uasmailhost.internal.admin.cam.ac.uk" options =
set transport remote_smtp

exim -d -bt ***@gmail.com

routing ***@gmail.com
--------> test_router router <--------
local_part=bar domain=gmail.com
checking domains
gmail.com in "@ : localhost : localhost.localdomain"? no (end of list)
gmail.com in "! +local_domains"? yes (end of list)
calling test_router router
test_router router called for ***@gmail.com
domain = gmail.com
search_open: wildlsearch "/etc/exim/jpb1"
search_find: file="/etc/exim/jpb1"
key="***@gmail.com" partial=-1 affix=NULL starflags=0
LRU list:
F/etc/exim/jpb1
End
internal_search_find: file="/etc/exim/jpb1"
type=wildlsearch key="***@gmail.com"
file lookup required for ***@gmail.com
in /etc/exim/jpb1
***@gmail.com in "*@admin.cam.ac.uk"? no (end of list)
***@gmail.com in "***@cam.ac.uk"? no (end of list)
***@gmail.com in "***@gmail.com"? no (end of list)
***@gmail.com in "*@gmail.com"? yes (matched "*@gmail.com")
lookup yielded: mailhost.internal.admin.cam.ac.uk
original list of hosts = "mailhost.internal.admin.cam.ac.uk" options =
expanded list of hosts = "mailhost.internal.admin.cam.ac.uk" options =
set transport remote_smtp

exim -d -bt ***@example.com

routing ***@example.com
--------> test_router router <--------
local_part=someaddress domain=example.com
checking domains
example.com in "@ : localhost : localhost.localdomain"? no (end of list)
example.com in "! +local_domains"? yes (end of list)
calling test_router router
test_router router called for ***@example.com
domain = example.com
search_open: wildlsearch "/etc/exim/jpb1"
search_find: file="/etc/exim/jpb1"
key="***@example.com" partial=-1 affix=NULL starflags=0
LRU list:
F/etc/exim/jpb1
End
internal_search_find: file="/etc/exim/jpb1"
type=wildlsearch key="***@example.com"
file lookup required for ***@example.com
in /etc/exim/jpb1
***@example.com in "*@admin.cam.ac.uk"? no (end of list)
***@example.com in "***@cam.ac.uk"? no (end of list)
***@example.com in "***@gmail.com"? no (end of list)
***@example.com in "*@gmail.com"? no (end of list)
***@example.com in "*"? yes (matched "*")
lookup yielded: defaultmail.admin.cam.ac.uk
original list of hosts = "defaultmail.admin.cam.ac.uk" options =
expanded list of hosts = "defaultmail.admin.cam.ac.uk" options =
set transport remote_smtp


Does that help ?

John
--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Drav Sloan
2012-12-10 12:35:08 UTC
Permalink
Post by Patric Falinder
Hi,
I've been using Postfix for many years and I've recently migrated some of
my servers to Exim.
In Postfix I've been using transport_maps to specify where a specific
domain or email-address should go.
In some cases I have a couple of users that are not on the same server as
domain.com smtp:[mail.domain.com]
In your routers section (both untested...)

domain_map:
driver = manualroute
condition = ${if eq {}{${lookup{$domain}lsearch{/path/to/mapfile}}}{no}{yes}}
route_list = * ${lookup{$domain}lsearch{/path/to/mapfile}}
allow_fail
allow_defer
address_map:
driver = redirect
data = ${lookup{$local_part@$domain}lsearch{/path/to/mapfile}
retry_use_local_part
allow_fail
allow_defer

The 'mapfile' should contain:

domain.com: server.to.route.this.to
***@domain.com: ***@domain.com

Regards

D.
--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Loading...