Using Postfix (2.11.3) I want to redirect all mail to an external address.
/etc/postfix/main.cf
:
virtual_alias_maps = regexp:/etc/postfix/rewrite
/etc/postfix/rewrite
:
/^.+$/ hijacked@example.com
Sending mail to destination@example.net
, the following error occurs:
[...] to=<hijacked@example.com>, orig_to=<destination@example.net> [...] status=bounced (User unknown in virtual alias table)
Documentation says:
Valid recipient addresses are listed with the virtual_alias_maps parameter. The Postfix SMTP server rejects invalid recipients with "User unknown in virtual alias table".
Turns out, the error has to do something with validation of virtual alias domains: virtual_alias_domains
by default is $virtual_alias_maps
, setting it to anything else (to a non-matching domain or even leaving it empty) resolves the issue.
Another solution I found in an answer is giving the regular expression in another form:
/^.+@.+$/ hijacked@example.com
So my question is, how does validation of alias domains works when using regular expression tables for virtual aliasing? Why does setting virtual_alias_domains
to anything else solves the issue? How is the above two, address-mapping-wise equivalent patterns different?
Output of postconf -n
is:
config_directory = /etc/postfix
inet_interfaces = loopback-only
inet_protocols = ipv4
mydestination =
myhostname = example.org
myorigin = $myhostname
virtual_alias_domains =
virtual_alias_maps = regexp:/etc/postfix/rewrite
postconf -n
to help you better? – clement Jul 26 '15 at 15:57