I want to set up catch-all email on a domain, but also retain the ability to except certain email accounts, such that, if an email is sent to an excepted account, it is bounced back with an "account does not exist" error. What are my options for making this happen? Remotely hosted or self-hosted solutions are fine. Linux-based solutions are preferred in case of self-hosting.
2 Answers
sendmail
with the following virtusertable
entries will do this:
[email protected] fred
[email protected] error:nouser 550 User unknown
@example.com user294732
-
-
@Zulan I'm afraid I have no idea, as I don't use postfix. I suspect not, though. Oct 3, 2015 at 23:43
You could accomplish this using Postfix's PCRE tables. Configure it with postconf
:
postconf -e "virtual_alias_maps=pcre:/etc/postfix/virtusertable"
And an e.g. /etc/postfix/virtusertable
would look like this:
/^alex@example\.com$/ alex
/^barry@example\.com$/ barry
/(?<!^corey|dave)@example\.com$/ catch-all
Using this, alex
and barry
aliases will get delivered, corey
and dave
will get rejected and everything else will get routed to catch-all.
-
This needs the package
postfix-pcre
on ubuntu. Otherwise there will be errors!– ZulanOct 3, 2015 at 19:26 -
There is an extensive discussion about this here: linuxquestions.org/questions/linux-server-73/… - if/endif can be an alternative to the scracy
?<!
regex.– ZulanOct 5, 2015 at 17:10