Skip to main content

Procmail to execute a script and redirect mail to SPAMCOP

yum install procmail

ls /usr/bin/procmail
/usr/bin/procmail*


cat /home/user/.procmailrc
#Whatever recipes you'll use
#The order of the recipes is significant
:0
| /home/username/mime.sh


in filter you can set rules to pipe

 ##Rule3
if
 $h_X-Spam-Status: begins "Yes"
then
 pipe "/usr/bin/procmail -Y -a /home/user/.procmailrc"
endif












 mime.sh

#!/bin/sh

# ENTER PATH OF THE EMAILS THAT ARE TO BE SUBMITTED TO SPAMCOP
FPATH="/home/user/mail/domain/spam-redirect-test/cur/"
FPATH2="/home/user/mail/domain/spam-redirect-test/new/"
# ENTER YOUR SPAMCOP EMAIL ADDRESS
EMAIL="quick.*******@spam.spamcop.net"

#################################################################
#################################################################

cd $FPATH

for FILENAME in *
do

        # Create email and submit it to the supplied spamcop address
        /usr/local/bin/mime-construct \
        --subject "`cat $FILENAME | grep Subject: | cut -d : -f2 | head -1`" \
        --attachment "Original message" \
        --type message/rfc822 \
        --encoding base64 \
        --file $FILENAME \
        --to "$EMAIL"

        # Train this email to be spam to the bayesian SA filters
        #sa-learn --spam $FILENAME

        # Delete email
/bin/rm $FILENAME
done
cd $FPATH2
for FILENAME in *
do

        # Create email and submit it to the supplied spamcop address
        /usr/local/bin/mime-construct \
        --subject "`cat $FILENAME | grep Subject: | cut -d : -f2 | head -1`" \
        --attachment "Original message" \
        --type message/rfc822 \
        --encoding base64 \
        --file $FILENAME \
        --to "$EMAIL"

        # Train this email to be spam to the bayesian SA filters
        #sa-learn --spam $FILENAME

        # Delete email
/bin/rm $FILENAME
done

Comments