Scapping pseudocode from tpml7
if header exist (postfix will checks via header_cheks)
no rewrite --> different instance
else
rewrite with virtual_alias_maps same instance
AFAIK postfix can redirect email if certain header exist. See REDIRECT feature at man header_checks.
Unfortunately - based on above pseudocode - your request is redirecting email if certain header doesn't exist. I already tried some simple workarounds. But because your request wasn't directly supported then this solution was little complicated. Especially this solution required to learning about postfix multi instance.
I'll write the outline here - not exact step by step -, feel free to ask if something was still vague.
To do that you need two multi instances. First instance is doing header_checks, Second instance is doing normal outgoing.
First instance will have two smtpd daemon defined in master.cf
. One daemon (default) listen at *:25, the second one listen at 127.0.0.1:12525.
Second instance will listen at 127.0.0.1:22525
First instance
##main.cf
# your header filter
header_checks = pcre:/path/to/header_checks
# no rewriting
receive_override_options = no_address_mappings
# send to second instance
relayhost = [127.0.0.1]:22525
virtual_alias_maps = pcre:/your/catch-all
##master.cf
# second smtpd but with rewriting enabled
[127.0.0.1]:12515 inet n - n - - smtpd
-o receive_override_options=
# /path/to/header_checks
/^MyHeader/ FILTER smtp:[127.0.0.1]:12525
Second instance
Just setup like first postfix instance without header_checks, relayhost, virtual_alias_maps and receive_override_options (normal postfix instaltion). Set master.cf so it's only listen at [127.0.0.1]:22525. Set myhostname
so it will be different with first instance.