1

I successfully configured Postfix to deliver messages to virtual mailboxes.

I can set aliases and pipes inside /etc/postfix/virtual and mailboxes inside /etc/postfix/virtual_mailbox files.

However, whenever I set a catch-all domain and point to a remote email address, it overrides all other virtual mailboxes and virtual aliases set in postfix. How can I set a catch-all forwarding to the remote email address when virtual mailbox is enabled?

I set catch-all like this:

@mydomain.com     catchall@otherdomain.com

Thanks for your help!

3

The catchall should be in the virtual_alias_maps file (in your case /etc/postfix/virtual) and not in the virtual_mailbox file.

Take a look here, search the page for Mail forwarding domains and you'll find this example:

1 /etc/postfix/main.cf:
2     virtual_alias_domains = example.com ...other hosted domains...
3     virtual_alias_maps = hash:/etc/postfix/virtual
4 
5 /etc/postfix/virtual:
6     postmaster@example.com postmaster
7     joe@example.com        joe@somewhere
8     jane@example.com       jane@somewhere-else
9     # Uncomment entry below to implement a catch-all address
10     # @example.com         jim@yet-another-site
11     ...virtual aliases for more domains...
|improve this answer|||||
  • Thanks for your answer. Yes, I already tried adding @domain.com to my /etc/postfix/virtual table but once it's added, it overrides all other aliases and captures all emails. – Cem Nov 17 '11 at 16:14
  • @Cem actually the manual says the examples shows how one would implement a catch-all virtual alias that receives mail for every example.com address *not listed* in the virtual alias file. So it should work. Have you done postmap /etc/postfix/virtual after the modifications? – Mr Shunz Nov 17 '11 at 16:20
  • 1
    @Cem but where is your config? – c4f4t0r Jan 16 '14 at 15:42
  • As @MrShunz says, "for every example.com address not listed in the virtual alias file". This was what caught me out. It seems that the @example.com target@example.net syntax is only intended for use with true mail-forwarding domains; that is, domains for which all email is forwarded to one or more other domains. This means that e.g. if you have alice@example.com, bob@example.com, and catchall@example.com; and you want other *@example.com mail to be sent to catchall@example.com, then you need to specify "redundant" aliases for alice and bob ... – Jivan Pal Mar 6 at 10:56
  • ... i.e. add the entries alice@example.com alice@example.com and bob@example.com bob@example.com to your virtual_alias_maps map. Honestly quite disappointing, and I am yet to find an alternative, simpler configuration for this use case, if one even exists. – Jivan Pal Mar 6 at 10:57
0

To us the simplest solution was giving THREE entries for virtual_alias_maps, they are executed in order until the first match eg.

/etc/postfix/main.cf:
virtual_alias_maps = 
    hash:/etc/postfix/virtual, 
    proxy:ldap:/etc/postfix/ldap/virtual_mail_exist_maps.cf, 
    hash:/etc/postfix/virtual_after_ldap

The first entry is a 'classic' local file virtual, it may forward from .com to .net domain if you need something like this, eg.

/etc/postfix/virtual:
    @mydomain.com @mydomain.net

The second entry is a database, sql or ldap or anything else. When an account matches, postfix serves exactly the mail it was queried for and exits here - successfully forwarding the mail to more or less itself (postfix logic :))

/etc/postfix/ldap/virtual_mail_exist_maps.cf
     server_host     = x
     server_port     = x
     ...
     result_format   = %s

The third entry is another simple local file. Postfix will do lookups here only if the database lookups do not succeed, here you can place your catch-all address

/etc/postfix/virtual_after_ldap
    @mydomain.net postmaster
|improve this answer|||||

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.