postfix discard or change Message-ID header based on another header line

Solution 1:

I need to be able to do this conditionally, meaning only on a specific occasion, which I can identify by looking at the other headers, I want to remove the Message-ID.

No you can't do it with header_checks. Postfix examines the rules on one header line at a time. In other words, the you can't modify one header line based on another header line. See man 5 header_checks in BUG section and this thread on postfix mailing list.

Many people overlook the main limitations of header and body_checks rules.

  • These rules operate on one logical message header or one body line at a time. A decision made for one line is not carried over to the next line.