On Fri, Mar 08, 2024 at 09:23:19PM +0200, Mailinglists35 via Postfix-users 
wrote:

> The postmap input looks like this:
>  
> echo -e    "Received: from [127.0.0.1] (web1dev [10.11.12.13])\n\tby 
> email.domain.tld (Postfix) with ESMTPS id C9056
>    7E002\n\tfor  <em...@gmail.com>; Fri,    8 Mar 2024 19:20:29 +0200 (EET)" 
> | postmap -q - pcre:/etc/postfix/header_checks
>    Received: from [127.0.0.1] (web1dev [10.11.12.13])     REPLACE Received: 
> from email.domain.tld (email.domain.tld. [1.2.3.4])
>  
> What I am doing wrong?

The problem is with the "postmap" command, not the regular expression.

    $ printf "foo\nbar\n" | postmap -q - "pcre:{{/foo/ a}, {/bar/ b}}"
    foo     a
    bar     b

By default, postmap reads a separate key from each input line.  For
simulating reading of message headers, you need the "-h" option:


    $ printf "X: foo\n\tbar\n" | postmap -hq - "pcre:{{/foo.*bar/ a}, {/bar/ 
b}}"
    X: foo
            bar a
        
And you DO NOT want or need a "/m" option for your pattern.  Your use of
"^" should match only at the start of the logical header, not at the
start some folded line.

-- 
    Viktor.
_______________________________________________
Postfix-users mailing list -- postfix-users@postfix.org
To unsubscribe send an email to postfix-users-le...@postfix.org

Reply via email to