Mailing List Archive

Routing for aliases
Hi,

I have the following case: I have users who have their mail-address
aliased to an external address. The moment a router resolves the alias
it doesn’t go again for the new target address through all routers but
jumps directly the router to my dnslookup-router which is used for
external mails and sends it out. Any idea how I get the mail through the
whole router-loop again?

Here is a part of the routing part where the new target address gets
generated and it then directly jumps into the dnslookup router

virtual_aliases_nowild router generated foobar@domain2.tld
errors_to=NULL transport=NULL
uid=unset gid=unset home=NULL
routed by virtual_aliases_nowild router
envelope to: foobar@originaltarget.tld
transport: <none>
locking /var/spool/exim/db/retry.lockfile
locked /var/spool/exim/db/retry.lockfile
EXIM_DBOPEN: file </var/spool/exim/db/retry> dir </var/spool/exim/db>
flags=O_RDONLY
returned from EXIM_DBOPEN: 0x8075db390
opened hints database /var/spool/exim/db/retry: flags=O_RDONLY
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Considering: foobar@domain2.tld
unique = foobar@domain2.tld
dbfn_read: key=R:domain2.tld
dbfn_read: key=R:foobar@domain2.tld
dbfn_read: key=R:foobar@domain2.tld:<moepmoep@somedomain.tld>
no domain retry record
no address retry record
foobar@domain2.tld: queued for routing
EXIM_DBCLOSE(0x8075db390)
closed hints database and lockfile
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
routing foobar@domain2.tld
--------> dnslookup router <--------
local_part=almanhoca domain=domain2.tld
checking domains
search_open: lsearch "/usr/local/etc/exim/conf/virtual_domains"
cached open
search_find: file="/usr/local/etc/exim/conf/virtual_domains"
key="domain2.tld" partial=-1 affix=NULL starflags=0 opts="ret=key"
LRU list:
:/usr/local/etc/exim/conf/virtual_domains
:/usr/local/etc/exim/conf/local_domains
:/usr/local/etc/exim/conf/accnt_disc
5//usr/local/etc/exim/redirects
:/usr/local/etc/exim/conf/secondary_filter_domains
End
internal_search_find: file="/usr/local/etc/exim/conf/virtual_domains"
type=lsearch key="domain2.tld" opts="ret=key"
file lookup required for domain2.tld
in /usr/local/etc/exim/conf/virtual_domains
lookup failed
search_open: lsearch "/usr/local/etc/exim/conf/local_domains"
cached open
search_find: file="/usr/local/etc/exim/conf/local_domains"
key="domain2.tld" partial=-1 affix=NULL starflags=0 opts="ret=key"
LRU list:
:/usr/local/etc/exim/conf/local_domains
:/usr/local/etc/exim/conf/virtual_domains
:/usr/local/etc/exim/conf/accnt_disc
5//usr/local/etc/exim/redirects
:/usr/local/etc/exim/conf/secondary_filter_domains
End
internal_search_find: file="/usr/local/etc/exim/conf/local_domains"
type=lsearch key="domain2.tld" opts="ret=key"
file lookup required for domain2.tld
in /usr/local/etc/exim/conf/local_domains
lookup failed
domain2.tld in
"lsearch,ret=key;/usr/local/etc/exim/conf/virtual_domains:lsearch,ret=key;/usr/local/etc/exim/conf/local_domains"?
no (end of list)
domain2.tld in "! +local_domains"? yes (end of list)
calling dnslookup router

Best,

Niels



--
## 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/
Re: Routing for aliases [ In reply to ]
On Tue, 19 Jan 2021 at 11:31, Niels Kobschätzki via Exim-users <
exim-users@exim.org> wrote:

> Hi,
>
> I have the following case: I have users who have their mail-address
> aliased to an external address. The moment a router resolves the alias
> it doesn’t go again for the new target address through all routers but
> jumps directly the router to my dnslookup-router which is used for
> external mails and sends it out. Any idea how I get the mail through the
> whole router-loop again?
>

A matching route was found and the mail routed correctly.
Maybe you want to re-order your routers - because routers are processed "in
order"...


--
Best regards,
Odhiambo WASHINGTON,
Nairobi,KE
+254 7 3200 0004/+254 7 2274 3223
"Oh, the cruft.", grep ^[^#] :-)
--
## 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/
Re: Routing for aliases [ In reply to ]
On 19 Jan 2021, at 9:36, Odhiambo Washington wrote:

> On Tue, 19 Jan 2021 at 11:31, Niels Kobschätzki via Exim-users <
> exim-users@exim.org> wrote:
>
>> Hi,
>>
>> I have the following case: I have users who have their mail-address
>> aliased to an external address. The moment a router resolves the
>> alias
>> it doesn’t go again for the new target address through all routers
>> but
>> jumps directly the router to my dnslookup-router which is used for
>> external mails and sends it out. Any idea how I get the mail through
>> the
>> whole router-loop again?
>>
>
> A matching route was found and the mail routed correctly.
> Maybe you want to re-order your routers - because routers are
> processed "in
> order"...

But there are several routers before the dnslookup-router and the
debug-output does not indicate that they are checked before.

Best,

Niels



--
## 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/
Re: Routing for aliases [ In reply to ]
On Tue, 19 Jan 2021 at 11:40, Niels Kobschätzki <niels@kobschaetzki.net>
wrote:

> On 19 Jan 2021, at 9:36, Odhiambo Washington wrote:
>
> > On Tue, 19 Jan 2021 at 11:31, Niels Kobschätzki via Exim-users <
> > exim-users@exim.org> wrote:
> >
> >> Hi,
> >>
> >> I have the following case: I have users who have their mail-address
> >> aliased to an external address. The moment a router resolves the
> >> alias
> >> it doesn’t go again for the new target address through all routers
> >> but
> >> jumps directly the router to my dnslookup-router which is used for
> >> external mails and sends it out. Any idea how I get the mail through
> >> the
> >> whole router-loop again?
> >>
> >
> > A matching route was found and the mail routed correctly.
> > Maybe you want to re-order your routers - because routers are
> > processed "in
> > order"...
>
> But there are several routers before the dnslookup-router and the
> debug-output does not indicate that they are checked before.
>
> Best,
>
> Niels
>


Is that so? Can we see the routers?


--
Best regards,
Odhiambo WASHINGTON,
Nairobi,KE
+254 7 3200 0004/+254 7 2274 3223
"Oh, the cruft.", grep ^[^#] :-)
--
## 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/
Re: Routing for aliases [ In reply to ]
On Tue, Jan 19, 2021 at 09:40:03AM +0100, Niels Kobsch?tzki via Exim-users wrote:
> But there are several routers before the dnslookup-router and the
> debug-output does not indicate that they are checked before.

Are they checked when you run "exim -d+route -bt foobar@domain2.tld"?
--
Eugene Berdnikov

--
## 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/
Re: Routing for aliases [ In reply to ]
On 19 Jan 2021, at 9:46, Odhiambo Washington wrote:

> On Tue, 19 Jan 2021 at 11:40, Niels Kobschätzki
> <niels@kobschaetzki.net>
> wrote:
>
>> On 19 Jan 2021, at 9:36, Odhiambo Washington wrote:
>>
>>> On Tue, 19 Jan 2021 at 11:31, Niels Kobschätzki via Exim-users <
>>> exim-users@exim.org> wrote:
>>>
>>>> Hi,
>>>>
>>>> I have the following case: I have users who have their mail-address
>>>> aliased to an external address. The moment a router resolves the
>>>> alias
>>>> it doesn’t go again for the new target address through all
>>>> routers
>>>> but
>>>> jumps directly the router to my dnslookup-router which is used for
>>>> external mails and sends it out. Any idea how I get the mail
>>>> through
>>>> the
>>>> whole router-loop again?
>>>>
>>>
>>> A matching route was found and the mail routed correctly.
>>> Maybe you want to re-order your routers - because routers are
>>> processed "in
>>> order"...
>>
>> But there are several routers before the dnslookup-router and the
>> debug-output does not indicate that they are checked before.
>>
>> Best,
>>
>> Niels
>>
>
>
> Is that so? Can we see the routers?

Sure

begin routers

filtering_secondary:
driver = manualroute
transport = remote_smtp
domains =
partial-lsearch,ret=key;/usr/local/etc/exim/conf/secondary_filter_domains
headers_remove = Subject
headers_add = ${if and { \
{>={$h_X-VISP-Spam-Score-Int:}{50}} \
{match_domain{$domain}{+tag_domains}} \
}{Subject: ***SPAM*** $h_Subject:}{Subject: $rh_Subject:}}
route_list = $domain
${lookup{$domain}lsearch{/usr/local/etc/exim/conf/secondary_filter_domains}}

exchange_internal_delivery:
driver = manualroute
domains = exchange.local
transport = remote_smtp
route_list = * exchange.de.inter.net

mailshield_resubmit:
driver = manualroute
transport = remote_smtp
condition = ${if eq {$received_protocol}{mailshield}{1}{0}}
headers_add = ${lookup ldap{LDAP_AUTH
ldap:///LDAP_USER_DN?savFilter?sub?(mail=${quote_ldap:$local_part@$domain})}{X-VISP-ShouldScan:
$value}{X-VISP-ShouldScan: 0}}
route_list = * mailshield1.domain.tld:mailshield2.domain.tld
hosts_randomize = true

virtual_spambox:
driver = manualroute
transport = spam_virtual_delivery
domains = lsearch,ret=key;VIRTUAL_DOMAINS_FILE
condition = ${if eq {$received_protocol}{spamdeliver}{1}{0}}
address_data = ${lookup ldap{LDAP_AUTH
ldap:///LDAP_USER_DN?mail?sub?(mail=${quote_ldap:$local_part_data@$domain_data})}{$value}fail}
route_list = *
no_more
.ifdef SRS

srs_reply_router:
driver = redirect
senders = *@+local_domains
srs = reverseandforward
data = ${srs_recipient}
allow_fail
allow_defer

.endif

.ifdef MAILOUT

massmail_mailout:
driver = manualroute
transport = remote_smtp
senders = nwildlsearch;/usr/local/etc/exim/conf/ratelimit_whitelist
domains = !+local_domains
route_list = * mmout1.domain.tld:mmout2.domain.tld

.endif

dynamic_reroute:
driver = manualroute
transport = remote_smtp
domains = dsearch,ret=key;//usr/local/etc/exim/redirects
route_list = *
${readfile{/usr/local/etc/exim/redirects/$domain_data}{}}

.ifdef SRS
dnslookup_srs:
driver = redirect
domains = ! +local_domains : ! +no_srs_domains
senders = ! : ! *@+local_domains
srs = forward
srs_alias = srs.snafu.de
data = ${quote_local_part:$local_part}@$domain
allow_fail
allow_defer
redirect_router = dnslookup

.endif

dnslookup:
driver = dnslookup
domains = ! +local_domains
transport = remote_smtp
.ifdef SRS
dnssec_request_domains = *
.endif
mx_fail_domains = googlemail.de
ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8 : 192.168.0.0/16 :
10.0.0.0/8 : 172.16.0.0/12 : other_ips_from_my_ip_range
no_more


.ifdef SRS

virtual_aliases_nowild_srs:
driver = redirect
domains = lsearch,ret=key;VIRTUAL_DOMAINS_FILE
senders = ! : ! *@+local_domains
srs = forward
srs_condition = ${if match_domain{${domain:${lookup ldap{LDAP_AUTH
ldap:///LDAP_ALIAS_DN?mailDestinationAddress?sub?(mail=${quote_ldap:$local_part_data@$domain_data})}{$value}fail}}}{+no_srs_domains}{0}{1}}
data = ${lookup ldap{LDAP_AUTH
ldap:///LDAP_ALIAS_DN?mailDestinationAddress?sub?(mail=${quote_ldap:$local_part_data@$domain_data})}{$value}fail}
allow_fail
allow_defer
file_transport = address_file
pipe_transport = address_pipe
modemask = 002
redirect_router = dnslookup

virtual_aliases_nowild:
driver = redirect
domains = lsearch,ret=key;VIRTUAL_DOMAINS_FILE
data = ${lookup ldap{LDAP_AUTH
ldap:///LDAP_ALIAS_DN?mailDestinationAddress?sub?(mail=${quote_ldap:$local_part@$domain_data})}{$value}fail}
allow_fail
allow_defer
file_transport = address_file
pipe_transport = address_pipe
modemask = 002
redirect_router = dnslookup

.else

virtual_aliases_nowild:
driver = redirect
domains = lsearch,ret=key;VIRTUAL_DOMAINS_FILE
data = ${lookup ldap{LDAP_AUTH
ldap:///LDAP_ALIAS_DN?mailDestinationAddress?sub?(mail=${quote_ldap:$local_part_data@$domain_data})}{$value}fail}
allow_fail
allow_defer
file_transport = address_file
pipe_transport = address_pipe
modemask = 002

.endif

virtual_aliases_file:
driver = redirect
domains = lsearch,ret=key;VIRTUAL_DOMAINS_FILE
condition = ${if exists
{/usr/local/etc/exim/conf/aliases/$domain_data}{1}{0}}
data =
${lookup{$local_part}lsearch{/usr/local/etc/exim/conf/aliases/$domain_data}}
allow_fail
allow_defer
file_transport = address_file
pipe_transport = address_pipe
modemask = 002

LDAP_MAILBOX = ${lookup ldap{LDAP_AUTH
ldap:///LDAP_USER_DN?mailbox?sub?(mail=${quote_ldap:$local_part@$domain})}{$value}{/}}

virtual_userfilter:
driver = redirect
domains = lsearch;VIRTUAL_DOMAINS_FILE
no_check_local_user
no_verify
no_expn
router_home_directory = LDAP_MAILBOX
transport_home_directory = LDAP_MAILBOX
require_files = exim:${home}/.exim_filter
file = ${home}/.exim_filter
check_ancestor
allow_filter
file_transport = address_file
pipe_transport = address_pipe
reply_transport = address_reply
directory_transport = address_directory
modemask = 002
user = pop
group = exim


virtual_localuser:
driver = accept
transport = local_virtual_delivery
domains = lsearch,ret=key;VIRTUAL_DOMAINS_FILE
require_files = pop:+${home}
address_data = ${lookup ldap{LDAP_AUTH
ldap:///LDAP_USER_DN?mail?sub?(mail=${quote_ldap:$local_part@$domain})}{$value}fail}
transport_home_directory = LDAP_MAILBOX
router_home_directory = LDAP_MAILBOX

virtual_localuser_folder:
driver = accept
transport = local_virtualfolder_delivery
domains = lsearch,ret=key;VIRTUAL_DOMAINS_FILE
caseful_local_part = true
local_part_suffix = /*
require_files = pop:+${home}
address_data = ${lookup ldap{LDAP_AUTH
ldap:///LDAP_USER_DN?mail?sub?(mail=${quote_ldap:$local_part@$domain_data})}{$value}fail}
transport_home_directory =
LDAP_MAILBOX/.${tr{${substr_1:$local_part_suffix}}{.}{:}}
router_home_directory =
LDAP_MAILBOX/.${tr{${substr_1:$local_part_suffix}}{.}{:}}

.ifdef SRS

virtual_aliases_wildcard_srs:
driver = redirect
domains = lsearch,ret=aliasfile;VIRTUAL_DOMAINS_FILE
senders = ! : ! *@+local_domains
srs = forward
srs_condition = ${if match_domain{${domain:${lookup ldap{LDAP_AUTH
ldap:///LDAP_ALIAS_DN?mailDestinationAddress?sub?(mail=${quote_ldap:$local_part@$domain})}{$value}fail}}}{+no_srs_domains}{0}{1}}
condition = ${extract{aliasfile} {$domain_data}}
data = ${lookup ldap{LDAP_AUTH
ldap:///LDAP_ALIAS_DN?mailDestinationAddress?sub?(mail=${quote_ldap:all.all@$domain})}{$value}fail}
allow_fail
allow_defer
file_transport = address_file
pipe_transport = address_pipe
modemask = 002
redirect_router = dnslookup

virtual_aliases_wildcard:
driver = redirect
domains = lsearch,ret=aliasfile;VIRTUAL_DOMAINS_FILE
condition = ${extract{aliasfile} {$domain_data}}
data = ${lookup ldap{LDAP_AUTH
ldap:///LDAP_ALIAS_DN?mailDestinationAddress?sub?(mail=${quote_ldap:all.all@$domain})}{$value}fail}
allow_fail
allow_defer
file_transport = address_file
pipe_transport = address_pipe
modemask = 002
redirect_router = dnslookup

.else

virtual_aliases_wildcard:
driver = redirect
domains = lsearch,ret=aliasfile;VIRTUAL_DOMAINS_FILE
condition = ${extract{aliasfile} {$domain_data}}
data = ${lookup ldap{LDAP_AUTH
ldap:///LDAP_ALIAS_DN?mailDestinationAddress?sub?(mail=${quote_ldap:all.all@$domain})}{$value}fail}
allow_fail
allow_defer
file_transport = address_file
pipe_transport = address_pipe
modemask = 002

.endif


system_aliases_file:
driver = redirect
domains =
partial-lsearch,ret=key;/usr/local/etc/exim/conf/local_domains
condition = ${if exists
{/usr/local/etc/exim/conf/aliases/$domain_data}{1}{0}}
allow_fail
allow_defer
data =
${lookup{$local_part}lsearch,ret=key{/usr/local/etc/exim/conf/aliases/$domain_data}}
user = pop
group = exim
file_transport = address_file
pipe_transport = address_pipe

system_aliases:
driver = redirect
domains =
partial-lsearch,ret=key;/usr/local/etc/exim/conf/local_domains
allow_fail
allow_defer
data =
${lookup{$local_part}lsearch,ret=key{/usr/local/etc/exim/conf/local_aliases}}
user = pop
group = exim
file_transport = address_file
pipe_transport = address_pipe

userforward:
driver = redirect
check_local_user
domains =
partial-lsearch,ret=key;/usr/local/etc/exim/conf/local_domains
file = $home/.forward
no_verify
no_expn
check_ancestor
file_transport = address_file
pipe_transport = address_pipe
reply_transport = address_reply

localuser:
driver = accept
check_local_user
domains =
partial-lsearch,ret=key;/usr/local/etc/exim/conf/local_domains
transport = ${if eq {${extract{maildir} {${domain}}}} {yes}
{local_delivery_maildir} {local_delivery}}
cannot_route_message = Unknown user


Niels


--
## 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/
Re: Routing for aliases [ In reply to ]
On 19 Jan 2021, at 9:48, Evgeniy Berdnikov via Exim-users wrote:

> On Tue, Jan 19, 2021 at 09:40:03AM +0100, Niels Kobschätzki via
> Exim-users wrote:
>> But there are several routers before the dnslookup-router and the
>> debug-output does not indicate that they are checked before.
>
> Are they checked when you run "exim -d+route -bt foobar@domain2.tld"?

yes, then it works as expected

Niels

--
## 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/
Re: Routing for aliases [ In reply to ]
On 19/01/2021 08:55, Niels Kobschätzki via Exim-users wrote:
>>>>> I have the following case: I have users who have their mail-address
>>>>> aliased to an external address. The moment a router resolves the
>>>>> alias
>>>>> it doesn’t go again for the new target address through all routers
>>>>> but
>>>>> jumps directly the router to my dnslookup-router which is used for
>>>>> external mails and sends it out. Any idea how I get the mail through
>>>>> the
>>>>> whole router-loop again?

> virtual_aliases_nowild:
>   driver = redirect
>   domains = lsearch,ret=key;VIRTUAL_DOMAINS_FILE
>   data = ${lookup ldap{LDAP_AUTH ldap:///LDAP_ALIAS_DN?mailDestinationAddress?sub?(mail=${quote_ldap:$local_part@$domain_data})}{$value}fail}
>   allow_fail
>   allow_defer
>   file_transport = address_file
>   pipe_transport = address_pipe
>   modemask = 002
>   redirect_router = dnslookup

That last line seems to speak to the behaviour you are seeing...
--
Cheers,
Jeremy

--
## 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/
Re: Routing for aliases [ In reply to ]
On 19 Jan 2021, at 10:19, Jeremy Harris via Exim-users wrote:

> On 19/01/2021 08:55, Niels Kobschätzki via Exim-users wrote:
>>>>>> I have the following case: I have users who have their
>>>>>> mail-address
>>>>>> aliased to an external address. The moment a router resolves the
>>>>>> alias
>>>>>> it doesn’t go again for the new target address through all
>>>>>> routers
>>>>>> but
>>>>>> jumps directly the router to my dnslookup-router which is used
>>>>>> for
>>>>>> external mails and sends it out. Any idea how I get the mail
>>>>>> through
>>>>>> the
>>>>>> whole router-loop again?
>
>> virtual_aliases_nowild:
>>   driver = redirect
>>   domains = lsearch,ret=key;VIRTUAL_DOMAINS_FILE
>>   data = ${lookup ldap{LDAP_AUTH
>> ldap:///LDAP_ALIAS_DN?mailDestinationAddress?sub?(mail=${quote_ldap:$local_part@$domain_data})}{$value}fail}
>>   allow_fail
>>   allow_defer
>>   file_transport = address_file
>>   pipe_transport = address_pipe
>>   modemask = 002
>>   redirect_router = dnslookup
>
> That last line seems to speak to the behaviour you are seeing...

Oh, right. Thanks a log. That was it. I have a look at my logs if I see
other problems coming up because of that. So far it is looking good.

Best

Niels

--
## 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/