Question

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 notify@domain.com

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.

Was it helpful?

Solution

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]+@domain.com

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top