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'm trying to work out how I can get postfix to accept email for any sub-domain of my main site. I don't have virtual domains, just a long list of sub-domains for local delivery. In specific, I'm feeding python@* into a Python using the alias file:

python:    |/www/

The Python can handle delivery from there. I envision this looking something along the lines of:

mydestination = encendio, localhost.localdomain, localhost, *

I'm running the latest version of postfix on Ubuntu (not rightly sure how to check the version).

Thanks in advance.

share|improve this question
up vote 12 down vote accepted

You can't use wildcards if you explicitly list the destinations in your Postfix config, but fortunately the $mydestination option accepts table lookups. So try setting $mydestination to a pcre map like this:

mydestination = pcre:/etc/postfix/mydestinations

Then create /etc/postfix/mydestinations:

/encendio/                  ACCEPT
/localhost\.localdomain/    ACCEPT
/localhost/                 ACCEPT
/.*\.mydomain\.com/         ACCEPT

Technically you could put anything at all in the place of "ACCEPT" as the result is ignored; just the presence of the match is sufficient:

Specify a list of host or domain names, "/file/name" or "type:table" patterns, separated by commas and/or whitespace. A "/file/name" pattern is replaced by its contents; a "type:table" lookup table is matched when a name matches a lookup key (the lookup result is ignored).

share|improve this answer
The regular expressions should be achored; see – Richard Hansen Apr 11 at 21:13

The pcre solution in the accepted answer works well, but you might want to consider anchoring the regexp to avoid getting hits on just part of the domain name.

/^encendio$/                  ACCEPT
/^localhost\.localdomain$/    ACCEPT
/^localhost$/                 ACCEPT
/^.*\.mydomain\.com$/         ACCEPT
share|improve this answer

* wont work.

You need to create relay-domains and put all your subdomains in there. 1 per line.

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.