0

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.

1
  • Any common mailserver on unix can do this.
    – Jenny D
    Jun 23, 2014 at 12:01

2 Answers 2

2

sendmail with the following virtusertable entries will do this:

[email protected]                fred
[email protected]              error:nouser 550 User unknown   
@example.com                    user294732  
2
  • This doesn't seem to work with postfix. Should it?
    – Zulan
    Oct 3, 2015 at 19:31
  • @Zulan I'm afraid I have no idea, as I don't use postfix. I suspect not, though.
    – MadHatter
    Oct 3, 2015 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.

2
  • This needs the package postfix-pcre on ubuntu. Otherwise there will be errors!
    – Zulan
    Oct 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.
    – Zulan
    Oct 5, 2015 at 17:10

Not the answer you're looking for? Browse other questions tagged .