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.
Asked
Active
Viewed 939 times
0
-
Any common mailserver on unix can do this. – Jenny D Jun 23 '14 at 12:01
2 Answers
2
sendmail
with the following virtusertable
entries will do this:
fred@example.com fred
bounce@example.com error:nouser 550 User unknown
@example.com user294732

MadHatter
- 79,770
- 20
- 184
- 232
-
-
@Zulan I'm afraid I have no idea, as I don't use postfix. I suspect not, though. – MadHatter Oct 03 '15 at 23:43
2
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.

Belmin Fernandez
- 10,799
- 27
- 84
- 148
-
This needs the package `postfix-pcre` on ubuntu. Otherwise there will be errors! – Zulan Oct 03 '15 at 19:26
-
There is an extensive discussion about this here: http://www.linuxquestions.org/questions/linux-server-73/postfix-how-to-reject-incoming-mail-as-in-sendmail's-error-nouser-671883/ - if/endif can be an alternative to the scracy `?<!` regex. – Zulan Oct 05 '15 at 17:10