I am trying to setup a "catchall" address. In my virtual_mailbox table I have emails setup like so:

select * from virtual_users;

 id | domain_id |      password     |           email
  3 |         1 | ***************** | drewag@domain.com
  4 |         1 | ***************** | catchall@domain.com

That works great on its own. When I try to add a virtual alias for the catchall:

select * from virtual_aliases;

 id | domain_id |      source       |        destination
  1 |         1 | @domain.com       | catchall@domain.com

Once I add that virtual_alias, all email is going to catchall and I can send any to drewag@domain.com.

Is there something I need to do to shift around the priority?

This is what I am getting in my postfix logs:

Oct 20 23:24:26 localhost postfix/qmgr[8002]: C23A711DF9: from=<drewag@example.com>, size=1712, nrcpt=1 (queue active)
Oct 20 23:24:26 localhost postfix/lmtp[8148]: C23A711DF9: to=<catchall@domain.com>, orig_to=<drewag@domain.com>, relay=domain.com[private/dovecot-lmtp], delay=0.42,     delays=0.4/0.01/0.01/0.01, dsn=2.0.0, status=sent (250 2.0.0 <catchall@domain.com> 8V9DA4q6ZFLVHwAA0J78UA Saved)
Oct 20 23:24:26 localhost postfix/qmgr[8002]: C23A711DF9: removed

migrated from superuser.com Oct 25 '13 at 1:50

This question came from our site for computer enthusiasts and power users.


I found the solution here (specifically in the "Black Magic" section: https://workaround.org/book/export/html/58

Essentially, aliases will always take precedence over the mailboxes. So to make this work, the actual email addresses need to be added to the aliases as well. Instead of having to duplicate the data, we can create an email2email mapping and add that to the alias mappings as well. In the case of PostgreSQL /etc/postfix/main.cf will include this:

# /etc/postfix/main.cf
virtual_alias_maps = pgsql:/etc/postfix/pgsql-virtual-alias-maps.cf,pgsql:/etc/postfix/pgsql-email2email.cf

Note: there are two different virtual_alias maps

Then pgsql:/etc/postfix/pgsql-email2email.cf looks like this:

user = mailuser
password = mailuserpass
dbname = mailserver
query = SELECT email FROM virtual_users WHERE email='%s';

Note: This is identical to the virtual_mailboxes_map config except we are selecting "email" instead of 1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.