Block email in Postfix based on the "From: " header address
Just to show that the suggestion feature when you enter a subject works, when I entered the subject for this question the first result was a link to Route mail in postfix to different relays based on subject. It's not what I was looking for, but it led me to look more closely at header_checks despite what is stated in the answer at the link in my question. A web search led me to How to filter mail with postfix header_checks, which was the answer I was looking for.
In my case this worked in /etc/postfix/header_checks:
/^From:.*partyfixx/ REJECT
I actually put a very rude message after "REJECT", but that's not appropriate to include here.
Here is the log entry for their most recent attempt:
Sep 25 01:41:54 mymailserver postfix/cleanup[19112]: F2A6428C3FD: reject: header From: The Party Fixx Company <[email protected]> from a9-98.smtp-out.amazonses.com[54.240.9.98]; from=<010001660e63cb43-c865ad08-e534-4fbd-acbe-ba6fed55ed25-000000@amazonses.com> to=<[email protected]> proto=ESMTP helo=<a9-98.smtp-out.amazonses.com>: 5.7.1 Rude message redacted!!!
The regex is case insensitive.
Other answers I found useful:
- What is the behavior difference between return-path, reply-to and from?
- What's the difference between Sender, From and Return-Path?