3

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;

/home/admin/postfix/virtual_domains:

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

/etc/postfix/main.cf:

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

/home/admin/postfix/virtual_aliases:

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

Any ideas how can I solve it ?

mailq
  • 17,023
  • 2
  • 37
  • 69
Andrew
  • 31
  • 2

1 Answers1

3

Sure. Just do this:

/home/admin/postfix/virtual_domains:

/((\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.

mailq
  • 17,023
  • 2
  • 37
  • 69