Le 11/12/2010 17:31, Ansgar Wiechers a écrit :
On 2010-12-10 thussvm wrote:
Because of a domain move we're doing, we're trying to add a reply-to
header in postfix when no reply-to header is already present. The rule
we're using is:

!/^Reply-To/ prepend Reply-To: "Support"<supp...@ourdomain.org>

However, since the check is being applied to each header line we get a
bunch of reply-to's prepended instead of just one. Is there a regex we
can use to say:

If no reply-to header exists anywhere in the headers
    then prepend one reply-to header

As others have already said: header_checks inspects one header at a time,
not all headers as a whole.

If your mail goes through Postfix only once, you could try prepending
some unique header (e.g. Subject or Message-ID) with the Reply-To
header:

   if /^message-id:/
     /^message-id:/ PREPEND Reply-To: "Support"<supp...@example.org>
   endif


That will add the Reply-To: header to all messages and may cause more than one such header to appear in a message, which would be incorrect (RFC 5322, section 3.6, page 20).

if OP wants to remove previously set Reply-To headers, then he can use

/^(Reply-To:.*)/        REPLACE X-WAS-$1

together with your suggestion.

he could also stack multiple smtpd listeners with their own cleanups and header_checks. but that's a bit convoluted. so unless OP tells us more, ...

However, that's merely a workaround (and an ugly one at that), not a
real solution.

And please use RFC 2606 domain names instead of some made-up fake domain
that may actually be a real domain belonging to someone else. That's why
the domains in RFC 2606 are reserved after all.

Regards
Ansgar Wiechers

Reply via email to