Filtering message headers with Sendmail v8

The following describes how to filter incoming email messages based on the presence and contents of certain headers using sendmail v8.

This technique is directly copied from, a discussion of how to bounce annoying messages from a particular service, but without the use of procmail or other client-level filters.

From: <>

If that's in every message, try this in your .m4 or .mc file:

HX-Sender: $>Check_XSender
D{MMsg}Spamming denied
R${MPat} $*	$#error $: 553 ${MMsg}
RX-Sender: ${MPat} $*	$#error $: 553 ${MMsg}

There are tabs betwen $* and $#.

More notes