procmail
[Top] [All Lists]

Procmail Rules - newbie

2003-10-29 04:55:47
Dear list's friend,

finally I'm subscribed to the list :-))) I searched the archive for access,
db, etc. and got any useful results.

First, I'm new in procmail. I've mailserver running
Sendmail+Procmail+SpamAssassin. I've set up SA as well (as spamd) and I
tried to write my own rules for procmail. They work, but not very good.
Please can anyone help me to tune these rules up ? They may be stupid, but
it shows what I want to get. And may be, it will be useful for others (after
tuning)...

Curently I'm checking From: header, but I'd check Received header (may be
the envelope-from part) - I do not know, how to write correct regexp, to
search for envelope-from.
I've created spam_lover user with correct mailbox here, and he would receive
all spams by these rules. It works, but not good (and it's very slow too, as
it always sends a copy to the rule). What is the correct way to redirect
mail to another user's mailbox ? I can not find it in examples, as all
redirects go to mailqueue/ folder.

Please, help me. Any suggestions are VERY welcome.

Peter Rosa



Here are my (newbie) rules:
######################################################################
SHELL=/bin/sh
VERBOSE=yes
ACCESS=/etc/mail/access
FREEMAILS=/etc/mail/freemails.txt
AWK=/usr/bin/awk
TEST=/bin/test
EGREP=/usr/bin/egrep
FMAIL=/usr/local/bin/formail

TO_HEAD=`${FMAIL} -x "To:"`
E__MAIL=`${FMAIL} -x "To:" | ${AWK} -F '<' '{ if ($2=="") print $1; \
          else print $2; }' | ${AWK} -F '>' '{ print $1 }'`
FROM_HEAD=`${FMAIL} -x "From:"`
SUBJ_HEAD=`${FMAIL} -x "Subject:"`

DOMAIN=`${FMAIL} -x "From:" | ${AWK} -F@ '{ print $2 }' | \
        ${AWK} -F '>' '{ print $1 }'`
IS_FREEMAIL=`${EGREP} -i ${DOMAIN} ${FREEMAILS} | wc -l`
IS_IN_ACCESS=`${EGREP} -i ${DOMAIN} ${ACCESS} | wc -l`

# score 15+: add to ACCESS db, send notification, delete mail
:0 Wc: access.lock
* ^X-Spam-Level: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
* !^X-Loop: NOTIFY
* ? ${TEST} ${IS_FREEMAIL} -lt 1
* ? ${TEST} ${IS_IN_ACCESS} -lt 1
| /etc/mail/addspam spam ${DOMAIN};
:0 Whc: notify.lock
* ^X-Spam-Level: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
* !^X-Loop: NOTIFY
| (${FMAIL} -X"" -a "X-Loop: NOTIFY" -a "Subject: *****SPAM***** Del"; \
   echo "There is a mail from ${FROM_HEAD},"; \
   echo "Subject: ${SUBJ_HEAD}"; \
   echo "It was deleted by procmail rules"; \
  $SENDMAIL -oi ${E__MAIL}
:0
* ^X-Spam-Level: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
* !X-Loop: NOTIFY
/dev/null

# score 10-14: add to ACCESS db, redirect to spam_lover
:0 Whc: access.lock
* ^X-Spam-Level: \*\*\*\*\*\*\*\*\*\*
* !^X-Loop: NOTIFY
* ? ${TEST} ${IS_FREEMAIL} -lt 1
* ? ${TEST} ${IS_IN_ACCESS} -lt 1
| /etc/mail/addspam spam ${DOMAIN};

# score 6-14: redirect to spam_lover
:0 Wc: spam_lover.lock
* ^X-Spam-Level: \*\*\*\*\*\*
* !^X-Loop: spam_lover(_at_)pro(_dot_)sk
* !^X-Loop: NOTIFY
| $FMAIL -A "X-Loop: spam_lover(_at_)pro(_dot_)sk" | \
  $SENDMAIL -oi spam_lover(_at_)pro(_dot_)sk
:0 Whc: notify.lock
* ^X-Spam-Level: \*\*\*\*\*\*
* !^X-Loop: spam_lover(_at_)pro(_dot_)sk
* !^X-Loop: NOTIFY
| (${FMAIL} -X "" -a "X-Loop: NOTIFY" -a "Subject: *****SPAM***** Redir"; \
   echo "There is a mail from ${FROM_HEAD},"; \
   echo "Subject: ${SUBJ_HEAD}"; \
   echo "It was redirected to spam_lover by procmail rules"; \
   echo "If you think, it is reasonable mail, contact admin !") | \
  $SENDMAIL -oi ${E__MAIL}
:0
* ^X-Spam-Level: \*\*\*\*\*\*
* !^X-Loop: spam_lover(_at_)pro(_dot_)sk
* !^X-Loop: NOTIFY
/dev/null


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>
  • Procmail Rules - newbie, Peter Rosa <=