On 10/6/2020 3:56 PM, Frank DiGennaro wrote:
Thanks for the reply. This is what I have in my 'virtual_users' file
verbatim. I've even kept the domain names and users the same.

# Regexp                                # User to forward to
/\d{10,}@fax.mobilepbx.net/                     asterisk (I've tried both
\d{10,} and [0-9]{10,} without success)

\d is a pcre construct that not all regexp libraries recognize.
You should anchor the expression to prevent unexpected matches.
The result should have a domain (even if it's @localhost) to prevent surprises.

/\[0-9]{10,}@mobilepbx.net/                     asterisk

Escaping the first [ makes it match a literal "[" instead of a character class. Don't do that.

/^[0-9]+@fax\.mobliepbx\.net$/   astr...@example.com





  -- Noel Jones


#/5555555...@mobilepbx.net/             asterisk (When I try a specific
number like this, this does work)
/.*@mobilepbx.net/                              mobilepbx

/.*@voipbiz.org/                                voipbiz

/.*@contessa.net/                               fr...@digennaro.com


When I do a couple of tests, this is what I get.

(10 digits) (No)
postmap -q 5555555...@mobilepbx.net regexp:/etc/postfix/virtual_users
mobilepbx

(11 digits) (No)
postmap -q 55555555...@mobilepbx.net regexp:/etc/postfix/virtual_users
mobilepbx

(Yes)
postmap -q nosuchu...@mobilepbx.net regexp:/etc/postfix/virtual_users
mobilepbx

(Yes)
postmap -q supp...@voipbiz.org regexp:/etc/postfix/virtual_users
voipbiz
postmap -q nosuchu...@voipbiz.org regexp:/etc/postfix/virtual_users
voipbiz

(Yes)
postmap -q nosuchu...@contessa.net regexp:/etc/postfix/virtual_users

fr...@digennaro.com

Thanks;
Frank


-----Original Message-----
From: owner-postfix-us...@postfix.org
[mailto:owner-postfix-us...@postfix.org] On Behalf Of Wietse Venema
Sent: Tuesday, October 6, 2020 1:37 PM
To: Postfix users <postfix-users@postfix.org>
Subject: Re: Forward email based on Regexps

Frank DiGennaro:
All;

     I've made progress with this problem. By adding virtual_alias_maps
= regexp:/etc/postfix/virtual_users at the bottom of main.cf and
adding the regexps below, and running "postmap
/etc/postfix/virtual_users ", the two catch-alls work fine, but the
"longer" matches do not and ultimately they get delivered to the catch-all
address. I'm almost there. What am I missing?

Thanks in advance;

Maybe you can show what you did. It is easy to make regexp mistakes.
Note that regexp and pcre tables are parsed in the specified order, and that
the first match wins.

You can test stuff with the postmap command.

postmap -q email-address pcre:/path/to/file

        Wietse


Reply via email to