On Sun, Nov 30, 2008 at 12:18 AM, Victor Duchovni <[EMAIL PROTECTED]> wrote: > It should work if the newline is part of a ${n} sub-pattern match: > > # ${3} matches Newline + folding white-space > /^(Received): (.*?)(\n[\t\x20])(.*)$/ > ${1}: ${2}${3}(my comment)${3}${4} > > With test.pcre containing the above, "postmap -q" yields: > > $ postmap -q "$(printf "Received: %s\n\t%s\n" abc def)" pcre:test.pcre > Received: abc > (my comment) > def > > showing the insertion of an additional line into the header. What is not > possible is the insertion of a literal newline in the Postfix replacement > text in indexed file, regexp table or policy service lookups.
The pcre example above indeed passes the newline through as mentioned. Here's an adjusted expression to fit my situation, as well as an example header after the replacement: main.cf: header_checks = /usr/local/etc/postfix/maps/header_checks.pcre header_checks.pcre: /^(Received): (.*?)(\n[\t\x20])(.*)$/ REPLACE ${1}: from smtp-auth (smtp-auth.mycompany.com [55.55.55.55]${3}${4} resulting replaced header- Received: from smtp-auth (smtp-auth.mycompany.com [55.55.55.55] (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: [EMAIL PROTECTED]) by smtp.mycompany.com (Postfix) with ESMTPSA id EA8E9B879 for <[EMAIL PROTECTED]>; Sun, 30 Nov 2008 11:58:51 -0500 (EST) The beauty is that all other header information besides the actual remote host is kept intact - in my eyes making this a perfect solution for my situation. Thanks Victor, and thanks to everyone else for their input.