Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Assuming my Postfix server serves the domain, I want it to accept mail for all the subdomains of except for and

At first I've tried using a regular expression that excludes these two subdomains:


But it didn't work. I wasn't sure if the problem is with the regular expression or whether Postfix's regular expression engine doesn't support conditionals, so I've decided to try and use conditionals of the table file. At this point my table looked like this:


if !/(in|mail)\.example\.com/
/.+\.example\.com/ OK


virtual_alias_domains = regexp:/etc/postfix/virtual_domains

But it didn't work either. What am I doing wrong?

share|improve this question
up vote 3 down vote accepted

Change this in

virtual_alias_domains = !/etc/postfix/not_these_domains.txt regexp:/etc/postfix/virtual_domains


And keep /etc/postfix/virtual_domains simple:

/.+@.+\.example\.com/    OK

But note: This only works for Postfix >2.4

share|improve this answer

If your Postfix is built with PCRE support, try using negative look-behind:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.