Amador
Amador

Reputation: 41

postfix-mysql regexp for partial catch-all

I just trying to make a partially catch-all email on my Postfix-mysql config. I think have problem on the regexp.

I want to send all notify-*@domain.com to [email protected]

I use the following email request (letters and numbers are valid):

notify-([a-zA-Z0-9])@domain.com

But all times, Postfix tell me that User unknown in virtual mailbox table.

This is my Postfix config

virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf,
mysql:/etc/postfix/mysql_virtual_alias_maps_regexp.cf,
mysql:/etc/postfix/mysql_alias_domain_maps.cf

/etc/postfix/mysql_virtual_alias_maps_regexp.cf

user = postfixadmin
password = XXXXXXXXXXXX
hosts = 127.0.0.1
dbname = postfixadmin
query = SELECT goto FROM alias WHERE '%s' REGEXP CONCAT('^',address,'$') AND     SUBSTRING(address,1,1) != '@' AND x_regexp = '1'

I think the problem is in the email regexp, due not errors in the log file, and the mysql database have the corrected values.

Upvotes: 3

Views: 1709

Answers (1)

Robin
Robin

Reputation: 9644

I'm bot sure to fully understand your issue, but if you want to select email starting with notify-, followed by any number of letters/digits, you need to use:

notify-[a-zA-Z0-9][email protected]

[...] is a character class, it means "one character, one that's inside the list". So you need to allow repetition with +.

Upvotes: 4

Related Questions