Exim4 SMTP – Rejected RCPT: Unrouteable Address When Using Data Lookup

emailemail-servereximsmtp

I'm trying to redirect emails originally sent to hello@example.com, to the mrxxx@example.com.

I have aliases file:

hello: mrxxx@example.com

And the following routers:

local_router:
  driver = accept
  domains = +local_domains
  local_parts = mrxxx
  transport = local_dst
  cannot_route_message = Unknown mailbox
  no_more

aliases_router:
  driver = redirect
  data = ${lookup{$local_part}lsearch{/etc/aliases}}
  cannot_route_message = Unknown mailbox
  allow_defer
  allow_fail
  no_more

local_dst transport looks like the following:

local_dst:
  driver = appendfile
  directory = /var/mail/$local_part/Maildir
  delivery_date_add
  envelope_to_add
  return_path_add
  maildir_format
  mode_fail_narrower = false

According to the debug info it all should work just fine:

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Testing hello@example.com
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Considering hello@example.com
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
routing hello@example.com
--------> local_router router <--------
local_part=hello domain=example.com
checking domains
example.com in "@ : example.com"? yes (matched "example.com")
example.com in "+local_domains"? yes (matched "+local_domains")
checking local_parts
hello in "mrxxx"? no (end of list)
local_router router skipped: local_parts mismatch
--------> aliases_router router <--------
local_part=hello domain=example.com
calling aliases_router router
rda_interpret (string): '${lookup{$local_part}lsearch{/etc/aliases}}'
 search_open: lsearch "/etc/aliases"
 search_find: file="/etc/aliases"
   key="hello" partial=-1 affix=NULL starflags=0
 LRU list:
   2/etc/aliases
   End
 internal_search_find: file="/etc/aliases"
   type=lsearch key="hello"
 file lookup required for hello
   in /etc/aliases
 lookup yielded: mrxxx@example.com
expanded: 'mrxxx@example.com'
file is not a filter file
parse_forward_list: mrxxx@example.com
extract item: mrxxx@example.com
aliases_router router generated mrxxx@example.com
  errors_to=NULL transport=NULL
  uid=unset gid=unset home=NULL
routed by aliases_router router
  envelope to: hello@example.com
  transport: <none>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Considering mrxxx@example.com
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
routing mrxxx@example.com
--------> local_router router <--------
local_part=mrxxx domain=example.com
checking domains
example.com in "@ : example.com"? yes (matched "example.com")
example.com in "+local_domains"? yes (matched "+local_domains")
checking local_parts
mrxxx in "mrxxx"? yes (matched "mrxxx")
calling local_router router
local_router router called for mrxxx@example.com
  domain = example.com
set transport local_dst
queued for local_dst transport: local_part = mrxxx
domain = example.com
  errors_to=NULL
  domain_data=NULL localpart_data=NULL
routed by local_router router
  envelope to: mrxxx@example.com
  transport: local_dst
mrxxx@example.com
    <-- hello@example.com
  router = local_router, transport = local_dst
search_tidyup called
>>>>>>>>>>>>>>>> Exim pid=16 (main) terminating with rc=0 >>>>>>>>>>>>>>>>

However emails get rejected:

2020-03-08 21:24:20.079 [14] H=mail-oi1-f173.google.com [209.85.167.173]:43081 I=[192.168.144.7]:25 X=TLS1.3:TLS_AES_128_GCM_SHA256:128 CV=no SNI="mail.example.com" F=<jane.doe@gmail.com> rejected RCPT <hello@example.com>: Unrouteable address

Any ideas?

# exim --version
Exim version 4.93 #3 built 18-Dec-2019 19:58:53
...

EDIT:

Running exim daemon in the debug mode revealed a bit different picture, it seems that my aliases_router is skipped and it continues recipient verification in the dnslookup router??

13 sender jane.doe@gmail.com verified ok
13 require: condition test succeeded in ACL "acl_check_rcpt"
13 processing "accept" (/etc/exim/exim.conf 470)
13 check hosts = +relay_from_hosts
13 host in ""? no (end of list)
13 host in "+relay_from_hosts"? no (end of list)
13 accept: condition test failed in ACL "acl_check_rcpt"
13 processing "accept" (/etc/exim/exim.conf 479)
13 check authenticated = *
13 accept: condition test failed in ACL "acl_check_rcpt"
13 processing "require" (/etc/exim/exim.conf 485)
13   message: nice hosts say HELO first
13 check condition = ${if def:sender_helo_name}
13                 = true
13 require: condition test succeeded in ACL "acl_check_rcpt"
13 processing "require" (/etc/exim/exim.conf 492)
13   message: relay not permitted
13 check domains = +local_domains : +relay_to_domains
13 cached yes match for +local_domains
13 cached lookup data = NULL
13 example.com in "+local_domains : +relay_to_domains"? yes (matched "+local_domains" - cached)
13 require: condition test succeeded in ACL "acl_check_rcpt"
13 processing "require" (/etc/exim/exim.conf 501)
13 check verify = recipient
13 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
13 Verifying hello@example.com
13 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
13 Considering hello@example.com
13 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
13 routing hello@example.com
13 --------> local_router router <--------
13 local_part=hello domain=example.com
13 checking domains
13 cached yes match for +local_domains
13 cached lookup data = NULL
13 example.com in "+local_domains"? yes (matched "+local_domains" - cached)
13 checking local_parts
13 hello in "mrxxx"? no (end of list)
13 local_router router skipped: local_parts mismatch
13 --------> aliases_router router <--------
13 local_part=hello domain=example.com
13 aliases_router router skipped: verify 2 0 0
13 --------> dnslookup router <--------
13 local_part=hello domain=example.com
13 checking domains
13 cached yes match for +local_domains
13 cached lookup data = NULL
13 example.com in "! +local_domains"? no (matched "! +local_domains" - cached)
13 dnslookup router skipped: domains mismatch
13 no more routers
13 ----------- end verify ------------
13 require: condition test failed in ACL "acl_check_rcpt"

Best Answer

The correct setup in my aliases_router turned out the following (pretty much a copy/paste from the Exim docs):

aliases_router:
  driver = redirect
  data = ${lookup{$local_part}lsearch{/etc/aliases}}
  cannot_route_message = Unknown mailbox

I'm not sure why no_more and no_verify (as mentioned in the comments) turned out the rogue settings in here. allow_defer and allow_fail doesn't seem to block anything, as these are only used to enable some features in Exim's filters.

If you have an explanation regarding no_more and no_verify settings, please leave a comment or post an answer and I'll happily accept it.