This was brought to my attention by someone in the #postfix IRC channel the other day and I felt it deserved some testing and passing on. The postconf(5) docs for the local_recipient_maps setting does not state whether the keys in this table should include a domain name or just a username part without the @domain suffix. The setting does, however, have a default of "proxy:unix:passwd.byname $alias_maps" and since alias_maps *is* documented to want just the username part and the unix #passwd file also only contains just the username (without an @domain suffix) then it can be implied that lookups should work and will be done on the username part without the @domain suffix, that said...
When a pcre table is added to alias_maps, and local_recipient_maps is kept at the default which includes $alias_maps, then pcre table entries appear to be looked up with the @domain suffix for the local_recipient_maps setting. This is inconsistent with the alias_maps setting which looks up only the username portion of the address in the pcre table. This was confirmed with the following test cases: alias_maps = hash:/etc/aliases pcre:/etc/postfix/alias_test.pcre local_recipient_maps = proxy:unix:passwd.byname $alias_maps (default) /etc/postfix/alias_test.pcre: /^\d{9}$/ pj $ telnet localhost 25 Trying ::1... Connected to localhost. Escape character is '^]'. 220 el7-test.***MASKED***.com ESMTP Postfix HELO example.com 250 el7-test.***MASKED***.com MAIL FROM: test@localhost 250 2.1.0 Ok RCPT TO: 123456789@localhost 550 5.1.1 <123456789@localhost>: Recipient address rejected: User unknown in local recipient table QUIT 221 2.0.0 Bye Connection closed by foreign host. ...changing alias_test.pcre appears to allow the same test above to work: $ telnet localhost 25 Trying ::1... Connected to localhost. Escape character is '^]'. 220 el7-test.***MASKED***.com ESMTP Postfix HELO example.com 250 el7-test.***MASKED***.com MAIL FROM: test@localhost 250 2.1.0 Ok RCPT TO: 123456789@localhost 250 2.1.5 Ok DATA 354 End data with <CR><LF>.<CR><LF> To: 123456789@localhost From: test@localhost This is a test . 250 2.0.0 Ok: queued as 7D36790160 QUIT 221 2.0.0 Bye Connection closed by foreign host. ...but then ends up bouncing (from postfix logs): May 4 04:39:21 el7-test postfix/smtpd[20796]: connect from el7-test[::1] May 4 04:40:28 el7-test postfix/smtpd[20796]: 7D36790160: client=el7-test[::1] May 4 04:41:23 el7-test postfix/cleanup[20799]: 7D36790160: message-id=<20150504044028.7D36790160@el7-test.***MASKED***.com> May 4 04:41:23 el7-test postfix/qmgr[20794]: 7D36790160: from=<test@localhost>, size=359, nrcpt=1 (queue active) May 4 04:41:23 el7-test postfix/local[20801]: 7D36790160: to=<123456789@localhost>, relay=local, delay=59, delays=59/0.02/0/0.01, dsn=5.1.1, status=bounced (unknown user: "123456789") May 4 04:41:23 el7-test postfix/bounce[20802]: 7D36790160: sender non-delivery notification: E33DC901BB May 4 04:41:23 el7-test postfix/qmgr[20794]: 7D36790160: removed Adding *both* entries to alias_test.pcre: /^\d{9}$/ pj /^\d{9}@localhost$/ pj ... and repeating the above test works: May 4 04:46:38 el7-test postfix/smtpd[20809]: connect from el7-test[::1] May 4 04:46:52 el7-test postfix/smtpd[20809]: C44FD90160: client=el7-test[::1] May 4 04:47:06 el7-test postfix/cleanup[20812]: C44FD90160: message-id=<20150504044652.C44FD90160@el7-test.***MASKED***.com> May 4 04:47:06 el7-test postfix/qmgr[20794]: C44FD90160: from=<test@localhost>, size=364, nrcpt=1 (queue active) May 4 04:47:06 el7-test postfix/local[20813]: C44FD90160: to=<pj@el7-test.***MASKED***.com>, orig_to=<123456789@localhost>, relay=local, delay=19, delays=19/0.02/0/0, dsn=2.0.0, status=sent (delivered to mailbox) May 4 04:47:06 el7-test postfix/qmgr[20794]: C44FD90160: removed May 4 04:47:09 el7-test postfix/smtpd[20809]: disconnect from el7-test[::1] helo=1 mail=1 rcpt=1 data=1 quit=1 commands=5 Changing alias_test.pcre back to the original state: /^\d{9}$/ pj ...and explicitly setting: local_recipient_maps = ...also allows the message to go through: May 4 04:51:23 el7-test postfix/local[20832]: AF6C890160: to=<pj@el7-test.***MASKED***.com>, orig_to=<123456789@localhost>, relay=local, delay=34, delays=34/0.01/0/0, dsn=2.0.0, status=sent (delivered to mailbox) Note this is all on: mail_version = 3.0.1 ...but this also happened with another user in #postfix on (I believe) an older version of postfix, so it's possible this (bug?) has been in postfix for quite some time. If this is the case then fixing it could actually raise backwards compatibility issues which may necessitate something more complicated than a simple straightforward fix. Peter