Host wildcard subdomains using postfix
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
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
with properly anchored and escaped regexps:
/^encendio$/ ACCEPT
/^localhost\.localdomain$/ ACCEPT
/^localhost$/ ACCEPT
/^.*\.mydomain\.example$/ 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).