Tomasz Chmielewski wrote:
Victor Duchovni wrote:

Anyone there adding custom headers in Postfix?
Use smtp_header_checks, defined in master.cf on the "smtp" service. Requires postfix 2.5 or newer.

http://www.postfix.org/postconf.5.html#smtp_header_checks

# master.cf
smtp      unix  -       -       n       -       -       smtp
  -o smtp_header_checks=regexp:/path/add_my_header

# add_my_header
/^/ PREPEND X-Custom: my header

This will prepent the custom header above *each* header of the
message. One needs to match a header that is present exactly once in
each outbound message. Perhaps a locally added "Received" header or
something else added on input.

Would such logic be possible then (not sure how Postfix syntax would look like here, or if it's possible at all)?

if !(^X-Custom: header)
PREPEND X-Custom: header
fi


This would make adding this header independent of everything else (and thus, be able to be replicated to other setups without any change).



If you mean, "add the custom header if it's not there already", then no, that's not possible.

Have your regexp match some header added by your server as Viktor suggested. A Received: or maybe Message-id: might be a good choice.

  -- Noel Jones

Reply via email to