OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: catch all taking emails of valid email accounts

From: mouss (moussnetoyen.net)
Date: Wed Oct 01 2008 - 14:35:04 CDT


Chris St Denis wrote:
> I have some email addresses defined (example.com of course is not the
> real domain)
>
> davidexample.com
> opsexample.com
> tedexample.com
> yolandaexample.com
>
> and a catch all to opsexample.com
>
>
> when an email is sent to an address like yolandaexample.com it gets
> sent to opsexample.com

This is a FAQ. a catchall really means "catch all". and anyway, postfix
has no configuration called "catchall". what you are using is a wildcard
virtual alias. and virtual aliases apply to all mail.

What you want is an "identity mapping" (map an address to itself) for
valid addresses:

davidexample.com davidexample.com
tedexample.com tedexample.com
...

These will prevet the wildcard alias from being used (because a match is
found and alias expansion stops since the result contains the key).

since you store users in postgres, you can use something like this:

virtual_alias_maps =
        proxy:pgsql:/usr/local/etc/postfix/pgsql_identity_mapping.cf
        cdb:/usr/local/etc/postfix/virtual_alias

where the pgsql_identity_mapping.cf has a query that returns the user
(which is the key of the search query) if it is found in your virtual
mailbox table:

...
query = select %s from yourvirtualmailboxtable where '%s' = email

This has been discussed here many times. you may find more infos in the
archives (search for catchall and/or "identity mapping").

>
> Oct 1 11:11:35 barium postfix/pipe[53799]: DFC9410E463:
> to=<opsexample.com>, orig_to=<yolandaexample.com>, relay=maildrop,
> delay=0.06, delays=0.01/0/0/0.04, dsn=2.0.0, status=sent (delivered via
> maildrop service)
>
> Why is it delivering to the catch all instead of the virtual_mailbox
> account?
>

virtual_alias_maps apply to _all_ mail. yes, _all_ mail. so if you do

fooyahoo.com bargmail.com

it will redirect the first to the second, even if these aren't your
domains.

> [snip]