Postfix, virtual aliases and catchall for undefined addresses

If you include catch all email address in virtual alias then it will work.

in main.cf:

 virtual_alias_maps = hash:/etc/postfix/virtual

in virtual:

[email protected]           [email protected]
[email protected]           [email protected]
...
[email protected]        [email protected]
@example.com                [email protected]

So, I figured it out. Some people suggest that the catch-all has to be on top of the virtual alias file, but I tried that before and it did not help (though I found that solution quite logical).

What worked is:

  1. Set mydestination=localhost (that is not $myhostname)
  2. Add the catchall on top of the virtual alias file: @domain.com catchall-account@localhost
  3. Add all other virtual aliases below: [email protected] contact@localhost

The example assumes you have UNIX users named catchall-account and contact. Mails to [email protected] will be delivered to the contact user while all other mail will be delivered to the catch-all account.

Maybe this is not necessary in all cases, but in my special case I want to use an account to save mail for some addresses, but mail sent directly to that account should end up in the catch-all.

After all, looks like Postfix is not working it's way through the virtual aliases from top to bottom, and additionally catch-alls have some special priority. I will be glad about further comments in case someone is actually able to explain this behaviour.

Tags:

Alias

Postfix