user4564085
user4564085

Reputation:

Postfix mysql catch-all email

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 | [email protected]
|  2 |         1 | mypassword | [email protected]

My alias table:

+----+-----------+------------------------+-----------------------+
| id | domain_id | source                 | destination           |
+----+-----------+------------------------+-----------------------+
|  1 |         1 | @example.com           | [email protected]
|  2 |         1 | [email protected] | [email protected]

According to that, if someone sends a mail to [email protected] it should be delivered to [email protected], while any other mail directed to @example.com should be delivered to [email protected]. I tested my configuration and it seems to work:

user@myserver:~# postmap -q [email protected] mysql:/etc/postfix/mysql-virtual-alias-maps.cf
[email protected]
user@myserver:~# postmap -q [email protected] mysql:/etc/postfix/mysql-virtual-alias-maps.cf
[email protected]

Then I did a real test sending a mail with an external account to [email protected] and to [email protected]: both were delivered to [email protected], as opposed to what the configuration says. So my question is what could I have done wrong?
Any help will be appreciated

Upvotes: 2

Views: 1755

Answers (0)

Related Questions