2

I setup my mailserver with postfix, dovecot and mysql. Now I wanted to add a catch-all address to receive all the emails not directed to a specific user.
This is my actual configuration:

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

Query to check aliases (as mentioned here):

SELECT destination FROM virtual_aliases WHERE source='%s' UNION ALL SELECT destination FROM virtual_aliases WHERE source='@%d' AND NOT EXISTS (SELECT destination FROM virtual_aliases WHERE source='%s')

My users table:

+----+-----------+------------+----------------------+
| id | domain_id | password   | email                |
+----+-----------+------------+----------------------+
|  1 |         1 | mypassword | catch-all@example.com
|  2 |         1 | mypassword | me@example.com

My alias table:

+----+-----------+------------------------+-----------------------+
| id | domain_id | source                 | destination           |
+----+-----------+------------------------+-----------------------+
|  1 |         1 | @example.com           | catch-all@example.com
|  2 |         1 | another-me@example.com | me@example.com

According to that, if someone sends a mail to another-me@example.com it should be delivered to me@example.com, while any other mail directed to @example.com should be delivered to catch-all@example.com. I tested my configuration and it seems to work:

user@myserver:~# postmap -q another-me@example.com mysql:/etc/postfix/mysql-virtual-alias-maps.cf
me@example.com
user@myserver:~# postmap -q test@example.com mysql:/etc/postfix/mysql-virtual-alias-maps.cf
catch-all@example.com

Then I did a real test sending a mail with an external account to another-me@example.com and to test@example.com: both were delivered to catch-all@example.com, as opposed to what the configuration says. So my question is what could I have done wrong?
Any help will be appreciated

Community
  • 1
  • 1
  • I know this is an older post, but I used postfixadmin web based tool and it works well for this purpose. I followed the below tutorial. https://www.rosehosting.com/blog/set-up-a-mail-server-with-postfixadmin-and-mariadb-on-centos-7/ – Stephan Oct 12 '17 at 02:09

0 Answers0