I have a problem with my configuration of postfix. I wanted to set up a catch-all email address for a domain. I have my virtual mailboxes and aliases saved in a postgresql database. Queries defined in files vdomains.cf, vmailbox.cf and valias.cf are these, respectively:
query = SELECT 1 FROM domains WHERE domain = '%s'
query = SELECT CONCAT(domains.domain, '/', mailboxes.address, '/') AS maildir FROM mailboxes LEFT JOIN domains ON mailboxes.domain = domains.id WHERE mailbox='%s'
query = SELECT dst FROM virtual_aliases WHERE src = '%s'
Those files are linked to main.cf by this block
virtual_mailbox_domains = pgsql:/etc/postfix/vdomains.cf
virtual_alias_maps = pgsql:/etc/postfix/valias.cf
virtual_mailbox_base = /srv/mail
virtual_mailbox_maps = pgsql:/etc/postfix/vmailbox.cf
virtual_uid_maps = pgsql:/etc/postfix/vuidmaps.cf
virtual_gid_maps = pgsql:/etc/postfix/vdomainmaps.cf
virtual_transport = lmtp:unix:private/dovecot-lmtp
This works perfectly for known recipients and server rejects all unknown recipients. Aliasing also works, if I define one address in the alias table mapping to another existing address in the mailbox table.
The problem is that the alias table gets resolved before the mailbox table, which creates a big problem when I want to alias a catch-all email like this:
src dst
@domain.com catchall@domain.com
This gets resolved before the actual mailbox and therefore all emails, including those intended for existing users, are forwarded to the catchall@domain.com address.
According to several answers here on stack or other sites, this setup should work and probably does for some people, so I believe that I am doing something wrong.
Last thing - my setup is Debian Jessie with Postfix 2.11.3.
Any help is much appreciated, thanks in advance