I have a Postfix (and Dovecot) server running, using MySQL to define the domain names, users and aliases. This is all running fine, but now I want to add a catch-all to a domain where I already have some users defined for. I added the user in the virtual_users table, and while I can connect to it and send emails with it, all the emails that are sent to it are being captured by the catch-all. Is there a way to solve this?
Relevant configuration files and details:
/etc/postfix/main.cf:
virtual_transport = lmtp:unix:private/dovecot-lmtp
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-maps.cf
local_recipient_maps = $virtual_mailbox_maps
mysql virtual users table:
+----+-----------+--------------+------------------------+
| id | domain_id | password | email |
+----+-----------+--------------+------------------------+
| 2 | 1 | passwordhash | postmaster@example.com |
+----+-----------+--------------+------------------------+
mysql virtual aliases table:
+----+-----------+------------------------+-------------------------------+
| id | domain_id | source | destination |
+----+-----------+------------------------+-------------------------------+
| 2 | 1 | @example.com | catch-all@other.example.net |
+----+-----------+------------------------+-------------------------------+
Best Answer
By default postfix always lookup in
virtual_alias_maps
first. So, it always override the another entry in another maps (for example:alias_maps
andvirtual_mailbox_maps
). So we need to exclude email address defined invirtual_mailbox_maps
.In order to exclude it, we need make new mysql map for
virtual_alias_maps
in main.cfThen in mailbox.cf,define query
That's it. You need query so the result = key lookup. When this happens postfix won't aliasing the email to catchall user.
Reference: postfix tutorial