procmail
[Top] [All Lists]

Re: Filtering MS-Office Attachments

2009-07-03 09:05:29
* John Conover <conover(_at_)rahul(_dot_)net> [03.07.2009 06:50]:
Thomas =?iso-8859-1?Q?G=F6bel?= writes:
* John Conover <conover(_at_)rahul(_dot_)net> [02.07.2009 20:30]:
Thomas Goebel writes:

i want to add a filter which sends an auto-reply if there are
MS-Office files attached to the mail ...

    :0
    * 2147483647^0 $ 
^content-type:${ws}(multipart/(mixed|alternative|application|signed|encrypted))|(application/)
    * 2147483647^0 $ 
^content-disposition:${ws}attachment;${ws}.*name${ws}=${ws}${dq}.*\.${ext}(\..*)?${dq}${ws}${eol}
    * 2147483647^0 $ ^content-transfer-encoding:${ws}base64
    { MALICIOUS=true }

That works for me thanks! I just changed the line from you to:

      ext='(doc|xls|ppt|exe)'

But if i a change {MALICIOUS...} to

| formail -r -k | msmtp -t -a account < $HOME/.mailreply

Maybe try:

    FROM=`formail -rzt -xTo:`

or:

    FROM=`formail -rz -xTo:`

(depending on which address, the trusted, i.e., the "Return-Path:", or
"From", or user supplied, i.e., the "From:" or "Reply-To:", you want
the return mail to go to,) at the top of the MS detection script,
then:

    | msmtp "${FROM}" -a account < $HOME/.mailreply

Hi, this solved the formail and msmtp problem! =) 
I read on manpage that it is possible to do two or more actions for one
recipe.

procmailrc example:

:O 
* some filtering
        {
        :O c
        ! any(_at_)address(_dot_)org
        
        :O
        foo/
        }

I listet my filter below. It is the same like procmailrc example, but
the mail sent back to the sender is not saved in my local folder
$MAIL/gmx. Procmail just skips the part with the local folder. 

# Filtering attachments
:0
* 2147483647^0 $ 
^content-type:${ws}(multipart/(mixed|alternative|application|signed|encrypted))|(application/)
* 2147483647^0 $ 
^content-disposition:${ws}attachment;${ws}.*name${ws}=${ws}${dq}.*\.${ext}(\..*)?${dq}${ws}${eol}
* 2147483647^0 $ ^content-transfer-encoding:${ws}base64
* ! ^X-Loop: goebel(_dot_)thomas(_at_)gmx(_dot_)net
{
        # Folded whitespace
        ws='[    ]*($[   ]+)*'
        # Double quote
        dq='"'
        # End of line
        eol='$'
        # Microsoft Office file name extensions
        ext='(doc|xls|ppt|exe)'
        # Resend mail to sender
        TO=`formail -rtzxTo:`

        :O c
        *
        | msmtp -a gmx "$TO" < $HOME/.mailreply
        
        :O
        * ^TO.*goebel.thomas
        gmx/
}
 
-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments
____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail