On Thu, Mar 22, 2012 at 12:33:26PM +0100, Claudius wrote:
> I have a configuration/understanding problem with 
> virtual_alias_maps and a regexp to catch all my domains.
> 
> This is my config:
> 
> main.cf:
> virtual_alias_maps =
>     regexp:/etc/postfix/virtual_aliases_global.regexp,
> [...]
> 
> virtual_aliases_global.regexp:
> /^(postmaster|root|MAILER-DAEMON|abuse|admin)(\+.*)*@.*$/  postmaster
> /^(bin|daemon|named|nobody|uucp|www|ftp-bugs|postfix|manager|dumper|operator|decode)(\+.*)*@.*$/
> root
> 
> This works really great for:
> postmas...@myvirtualdomain.com
> postmas...@mylocaldomain.com
> postmaster+something@....
> 
> But sadly it also works for:
> postmas...@notmydomain.com
> 
> Is there a way to have the regexp match only domains listed in
> virtual_mailbox_domains?
> Or do I have to compile a file that has all my domains in it?

You do. In regexp/pcre you can enclose the LHS (local-part) matches 
in an IF/ENDIF loop with the domains:

if /\@(example\.com|(other|third)\.example)$/
... your LHS stuff ...
endif

(Escaping of the \@ is necessary in PCRE but not POSIX RE.)

With domain lists in SQL, this is trivial -- I have posted this
solution before, recently. Simply do the magic in a SQL query with 
hardcoded values for the LHS matches.

I do have my domain lists in SQLite, but I don't do this. I just add 
postmaster/abuse aliases when adding a domain. If this is something 
commonplace, you can script it.

It looks like you are duplicating alias_maps in virtual_alias_maps. 
You probably don't need all those aliases for each virtual domain. I 
think the purpose of all the default aliases(5) in alias_maps was 
originally to prevent Internet mail from being delivered to system 
and daemon accounts. These accounts must exist in the local passwd(5) 
database, but you don't want them getting mail.

Also note that alias_maps does this perfectly for $mydestination 
local(8) domains. The RHS (domain-part) is ignored.
-- 
  http://rob0.nodns4.us/ -- system administration and consulting
  Offlist GMX mail is seen only if "/dev/rob0" is in the Subject:

Reply via email to