On Tue, Mar 17, 2009 at 10:01:53AM -0400, Charles Marcus wrote:

> On 3/17/2009 9:43 AM, Erwan David wrote:
> > You may generate the pcre file with a line
> > /recipient_([...@_]+)@localdomain/    recipient+$...@localdomain
> > 
> > for each valid recipient. This would preserve the validation of
> > recipient at RCPT TO stage.
> 
> Interesting... and maybe a good candidate for my first usable scripting
> attempt.

Perl is the natural choice for this:

    $ echo u...@example.com |
        domain=example.com perl -lpe '
            s{^(.*)\...@\q$env{domain}\e$}
                {/^\Q$1\E_(.*)\...@\q$env{domain}\e\$/ 
$1+\${...@$env{domain}}o;'
    /^user_(.*)@example\.com$/ user+$...@example.com

In practice instead of "echo ... |" Perl would read a list of addresses from
a file. The "\Q...\E" construct is the critical ingredient for quoting PCRE
special characters in the address localpart and domain.

-- 
        Viktor.

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the "Reply-To" header.

To unsubscribe from the postfix-users list, visit
http://www.postfix.org/lists.html or click the link below:
<mailto:majord...@postfix.org?body=unsubscribe%20postfix-users>

If my response solves your problem, the best way to thank me is to not
send an "it worked, thanks" follow-up. If you must respond, please put
"It worked, thanks" in the "Subject" so I can delete these quickly.

Reply via email to