How to prevent incoming e-mails with an invalid "From:" header being rewritten as if it were from the local domain

The default option for Postfix 2.2 and later is to never rewrite message header addresses from remote SMTP clients.

This problem may arise if in /etc/postfix/main.cf, "local_header_rewrite_clients" is set to "permit_mynetworks".

If mail enters the Postfix queue multiple times, via a content filter, spam filter, or some other external process, additional passes through the Postfix queue will originate from $mynetworks. Mail received from $mynetworks would then be mistaken as local and allow for empty domains to be rewritten to the local domain.

To resolve this, in /etc/postfix/main.cf, set "remote_header_rewrite_domain = domain.invalid". This allows Postfix to rewrite message headers from remote SMTP clients, and appends the remote_header_rewrite_domain value to incomplete addresses.

Setting this would then allow Postfix to append "domain.invalid" to an incomplete address as seen below.

Ex:
     From: Postmaster <Postmaster>
->  From: Postmaster <Postmaster@domain.invalid>