On my server, I implement redirects using this router
virtual_aliases:
driver = redirect
allow_defer
allow_fail
data = ${lookup{$local_part@$domain}wildlsearch*@{/etc/vhosts/forwards}}
domains = /etc/vhosts/maildomains
qualify_preserve_domain
retry_use_local_part
and entries in /etc/vhosts/forwards
like
[email protected]: [email protected]
^.*@example2.com: [email protected]
This works fine and as intended. Now my customer asks me to change the second line to “forward all, with the exception of [email protected] and [email protected]”, as these attract too much spam.
Is there a nice way to implement this logic inside the /etc/vhosts/forwards
, or would I have to add another blacklisting router?
Just add a condition to the router:
If address is listed in the
/etc/vhosts/stoplist
no redirection will be performed.You can selectively bounce email in the alias file /etc/vhosts/forwards, or just have it disappear. See the documentation on special items in lists, aka alias files (bullet items 4 & 5 as of Oct-14-2015).
It seems that this is possible within the
forwards
file, by specifying no addresses to forward to:This seems to be documented behavior (and not just a lucky implementation detail):