Search code examples
mysqlemailpostfix-mtacatch-all

Configure wildcard catch-all email with Postfix


I have a setup using Postfix with a MySQL database to configure domains, accounts and aliases.

I can set up a catch-all address when using a @example.com mail and forward it to [email protected].

Now I want a more advanced catch-all, like user-%@example.com to forward all to [email protected] and prod-%@example.com forward to [email protected]. % should be any alpha-numeric letter combination like [email protected] or [email protected].

Is this possible or do I need to change my setup?


Solution

  • Seems feasible enough with slight effort; Postfix supports random user-created aliases via the recipient_delimiter configuration directive, so you could set recipient_delimiter = - and create [email protected] as an alias to [email protected], and user-%@example.com would resolve first via recipient_delimiter to [email protected], and from there via the alias map to [email protected]. (If you already have email addresses containing dashes in your domain, you'll need to choose a different delimiter, or those addresses will stop working.)