It is possible to set up regexp'd aliases, one could say that an regex'd alias is like a catch-all alias with conditions. This article will try to describe this.
First you need to set up the mailbox that should be the receiver. This is done inside the PostfixAdmin interface:
Virtual List --> Add Mailbox
The next step is to add the alias. If you want to do this from PostfixAdmin you will have to change or disable the regexp check in the file 'functions.inc.php' (search for 'pInvalidMailRegex'). However, this is not what I recommend. Instead add your alias as a SQL query. For MySQL this could serve as an example:
INSERT INTO alias VALUES ( '07[0236]-?[0-9]-?[0-9]{6}@domain.tld', 'receiver@domain.tld', 'domain.tld', NOW(), NOW(), 1 );
(The regexp in this example will add support for swedish mobile phone numbers.)
In PostfixAdmin you will now see your created regexp'd alias.
Next step is to add a new virtual map to the postfix configuration file. First you could copy your current alias map:
# cp /etc/postfix/mysql_virtual_alias_maps.cf /etc/postfix/mysql_virtual_alias_maps_regexp.cf
Open the new file 'mysql_virtual_alias_maps_regexp.cf' and edit the query-line, making the file look like this:
user = postfix password = password hosts = localhost dbname = postfix query = SELECT goto FROM alias WHERE '%s' REGEXP CONCAT('^',address,'$') AND SUBSTRING(address,1,1) != '@' AND active = '1'
Add the file to your 'main.cf' (after the 'mysql_virtual_alias_maps.cf'):
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf, mysql:/etc/postfix/mysql_virtual_alias_maps_regexp.cf, # [... alias domain maps ...]
Save and reload your postfix, and test.
REGEXP matching in MySQL does not use any index, therefore it will have a negative impact on performance. If you have lots of aliases, but only few of them are RegExp, consider to add a column with an index on it to the alias table:
`x_regexp` tinyint(1) NOT NULL DEFAULT '0' KEY `x_regexp` (`x_regexp`)
Set x_regexp = 1 on your RegExp entries and add "AND x_regexp = 1" to your query in the RegExp map. This avoids that MySQL has to check all aliases against the RegExp, and should therefore speed up the lookup.
MySQL and RegExp:
http://dev.mysql.com/doc/refman/5.1/en/regexp.html
A forum post on the use of LIKE:
http://sourceforge.net/projects/postfixadmin/forums/forum/676076/topic/3382025?message=7612883