4

I'm running postfix (2.9.6) with dovecot (2.2.5) and I two domains:

  1. example.com as a virtual_mailbox_domain
  2. example.org as a virtual_alias_domain

I'd like to set up two different catch-all rules for unknown users but it does not work as expected.

Using the configuration below the catch-all rule for example.com applies to both example.com and example.org addresses (i.e. all unkown mail is delivered to johndoe's catch_com mailbox, regardless of example.org or example.com addresses). Removing the @example.com rule causes the @example.org rule to work propperly (mail delivered to johndoe's catch_org mailbox).

main.cf:

recipient_delimiter = +

virtual_mailbox_domains = example.com
virtual_mailbox_maps = hash:/opt/local/etc/postfix/virtual_mailbox

virtual_alias_domains = example.org
virtual_alias_maps = hash:/opt/local/etc/postfix/virtual_alias

master.cf

dovecot   unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail:vmail argv=/opt/local/libexec/dovecot/dovecot-lda -f ${sender} -d ${user}@${nexthop} -m ${extension}

virtual_mailbox:

johndoe@example.com         example.com/johndoe 

virtual_alias:

@example.org            johndoe+catch_org@example.com
@example.com            johndoe+catch_com@example.com

Adding the catchall rule to virtual_mailbox does not work because as I have read somewhere using dovecot-lda causes catchall rules in the virtual_mailbox to be ignored.

2

This is expected behavior from postfix. Virtual Alias will be checked first before any other alias. So the catchall of example.com /opt/local/etc/postfix/virtual_alias will routes your email before /opt/local/etc/postfix/virtual_mailbox.

In your case johndoe+catch_org will recursively mapped to virtual_alias again so it will matched with johndoe+catch_com.

If you setup catchall to another mailbox in same domain, then you can setup catchall in virtual_mailbox_maps. Add this line in bottom of /opt/local/etc/postfix/virtual_mailbox

@example.com    example.com/johndoe

The downside is you can't differentiate the email between example.com catchall or example.org catchall. For dovecot case, I can't confirm this scheme will work or not.


Another ugly solution is put the non-catchall account of example.com in /opt/local/etc/postfix/virtual_alias. For example:

# account with mailbox
john@example.com        john@example.com
doee@example.com        doee@example.com
abcd@example.com        abcd@example.com

# for example.org domain catch all
johndoe+catch_org@example.com     johndoe+catch_org@example.com 

@example.org            johndoe+catch_org@example.com
@example.com            johndoe+catch_com@example.com

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.