procmail
[Top] [All Lists]

Filter attachments: reject with notification(s)

2004-01-26 08:11:36
Hello,

I'm trying to setup a .procmailrc file to reject emails with attachments with notification. The sender will receive an email that indicate that his email was rejected because it contains bad attachments (pif, scr, exe, bat, etc...).

I need to make a reject notification, because I can't be sûre it's just a virus. I can't delete an email without any warning...

Here is my receipe :


========== .procmailrc ===========
#
# Procmail Script to block attachments

LOGFILE=$HOME/.procmail-log
VERBOSE=on
EMAIL=test(_at_)mydomain

ext='(bat|com|exe|pif|vb|lnk|scr|reg|chm|wsh|js|inf|shs|job|ini|shb|scp|scf|wsc|sct|dll)'


ws = '[  ]*($[   ]+)*'
dq = '"'
eol='$'
#

:0 B
* -3^0
* 4^0 $ name${ws}=${ws}${dq}.*\.${ext}(\..*)?${dq}${ws}${eol}
* 4^0 $ begin${ws}[0-9]+${ws}.*\.${ext}(\..*)?${ws}${eol}
{

        TEMP_TXT=$HOME/.procmail_temp_txt.txt
        KEY=`cat /proc/uptime | md5sum`
        DATE=`date '+%Y%m%d%H%M%S'`
        TIME_SEC=`date +%s`
        PID=$$
        QUEUE_ID=`ps | md5sum | cut -c1-8`
        FULLHOSTNAME=`hostname -f`

        :0 hbciw : ${TEMP_TXT}.lock
        | head -100 > ${TEMP_TXT}_$KEY

        :0 bhi
        | (formail -rt  -A "X-Loop: $EMAIL"    \
           -A "MIME-Version: 1.0" \
-A "Content-Type: multipart/report; report-type=delivery-status; boundary=\"$QUEUE_ID.$TIME_SEC/$FULLHOSTNAME\"" \
           -A "Message-Id: <$DATE(_dot_)$PID(_at_)$FULLHOSTNAME>" \
           -A "X-UIDL: $KEY"   ; \
echo -e "This is a MIME-encapsulated message.\n\n--$QUEUE_ID.$TIME_SEC/$FULLHOSTNAME\nContent-Description: Notification\nContent-Type: text/plain\n" ; \
           cat $HOME/badfile-procmail.txt ; \
echo -e "--$QUEUE_ID.$TIME_SEC/$FULLHOSTNAME\nContent-Description: Undelivered Message\nContent-Type: message/rfc822\n" ; \
           cat ${TEMP_TXT}_$KEY ; \
           rm -f ${TEMP_TXT}_$KEY ; \
           sleep 0 ) | /usr/sbin/sendmail -fdo-no-reply(_at_)cri74(_dot_)org -t 
-oi
}


=========== end .procmailrc ================


with


============ badfile-procmail.txt ==========
Your email was rejected because...

========== end badfile-procmail.txt ==========


Like you can see, it's a bit complex.
I would like to make it simplier.
Any suggestion ?

Is it possible to have process time for procmail so I can see if I will be able to put this filtering on 4000 users on single server (around 1 email each 2 seconds).


In a first time, I would like people to receive the reject notification in an Imap folder so they could know what an email that were destinated to them was rejected. I'm afraid using a CC will even reject the notification (because it contains the beginning of the email).
Do I need to write another block to put it in a folder ?

Thanks a lot for your help !

--
Fabien SALVI


_______________________________________________
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>