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

I would like to setup postfix to catch all emails from both: domain.tld & [randomsubdomain].domain.tld.

/((\w[\w\-]*)\.)+domain\.tld/ OK 

This rule works very good, but unfortunately it's catching only mails for [randomsubdomain].domain.tld. Any mail to domain.tld is blocked with below error:

NOQUEUE: reject: RCPT from mail-xx[209.xx]: 554 5.7.1 <test@domain.tld>: Relay access denied;


/((\w[\w\-]*)\.)+domain\.tld/ OK


virtual_mailbox_domains = pcre:/home/admin/postfix/virtual_domains
virtual_alias_maps      = pcre:/home/admin/postfix/virtual_aliases


/@((\w[\w\-]*)\.)+domain\.tld/ mailuser

Any ideas how can I solve it ?

share|improve this question

Sure. Just do this:


/((\w[\w\-]*)\.)+domain\.tld/ OK
/^domain\.tld/ OK

and /home/admin/postfix/virtual_aliases:

/@((\w[\w\-]*)\.)+domain\.tld/ mailuser
/@domain\.tld/ mailuser

Was an easy one, wasn't it? If you want it more complicated you could rework the second lines into the first one, but then it looks more ugly.

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.