Rejecting read receipt requests with Procmail

I preparation for my exit, I have been re-routing various routing bulk mail messages using “Procmail” recipes. While I was working on this, I got an email from a colleague who always requests read receipts for every message that he sends. Despite being asked to stop, messages continue to come in with read receipt requests. I thought “wouldn’t it be great if I could get procmail to just reject these messages outright?”

Consulting common references on Procmail was not helpful because they rely procmail having access to a full shell environment. My colleague Jim Lawson gave me the framework for a different solution which instead involves the use of the “:0fwc” construct to pipeline multiple procmail actions. Interesting is the use of the “appendmsg” command, for which I cannot find a reference anywhere. This work, though. Aggressive/Aggressive handling of read receipt requests achieved!

#Use ":0c:" below if you want to receive a copy of the original message instead of just rejecting it.
# Check to see if the message contains any of the following command read-receipt request headers:
* ^Disposition-Notification-To:|
# Prevent mail loops... mail loops are bad.
* ! ^X-Loop:
        | formail -pQUOTE: -k -r
        BODY=`formail -I ""`

        | formail -A"X-Loop:"
        -I"Subject: Rejected mail: Read Receipts not accepted by this account."
        #-I"To: ${REJECT}" 
        # scrape off the body
        | formail -X ""

        | appendmsg "Message rejected because it contains a read receipt request." 

        # put back the quoted body
        | appendmsg $BODY
        | sendmail -t