postfix-mysql regexp用于部分捕获

时间:2022-11-19 07:11:19

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

我只是想在我的Postfix-mysql配置上创建一个部分封闭的电子邮件。我觉得regexp有问题。

I want to send all notify-*@domain.com to notify@domain.com

我想把所有的notify-*@domain.com发送到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.

但是所有时候,Postfix都会告诉我虚拟邮箱表中的用户未知。

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

/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.

我认为问题出在电子邮件regexp中,因为日志文件中没有错误,而且mysql数据库有正确的值。

1 个解决方案

#1


3  

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开头的电子邮件,后面跟着任意数量的字母/数字,您需要使用:

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 +.

[…是一个字符类,它的意思是“一个字符,一个在列表里面”。所以你需要允许+的重复。

#1


3  

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开头的电子邮件,后面跟着任意数量的字母/数字,您需要使用:

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 +.

[…是一个字符类,它的意思是“一个字符,一个在列表里面”。所以你需要允许+的重复。