procmail
[Top] [All Lists]

Re: Parse body but not attachment

2002-01-04 16:03:22
Justin wrote,

| The problem is (I believe) that procmail isn't only parsing the body
| (and headers in this example), it's also parsing my attachment.

While you may see the "body" and the "attachment" as two different things,
they aren't to procmail nor to the MTA.  The body is everything after the
blank line that terminates the headers, no matter how many parts a MIME-ish
MUA may divide it into.  To MTAs and LDAs, the whole thing -- the first MIME
part that is the body in your viewpoint plus all additional MIME parts that
MUAs would call attachments -- is the body.

Somehow you'll have to capture the first MIME part of a multipart message in
a variable; then you can run your procmail conditions with that variable as
your search area.  I don't know much about this, but if you can use MATCH to
extract the boundary from the header into a variable named BOUNDARY, maybe
this ...

 PART1 searchallb # both start out unset

 :0bi
 * ^Content-Type:.*multipart
 PART1=| sed -ne "1,/^$BOUNDARY$/d" -e "/^$BOUNDARY$/q" -ep
 :0E
 { searchallb=B }

At that point a multipart message will have the first part saved as $PART1
and $searchallb unset; a single-part message will have $PART1 unset and a
single capital B in $searchallb.

Then the routine for each string can be like this:

 ##  --  advertising.com
 spamstring="advertising.com"
 spamfolder= # give a name if $spamstring is not the filename you want
# default search area will be HB if single-part, H if multipart
  :0 H$searchallb
# in either case, abort recipe if X-Loop is already in head
 * H ?? $ ! ^X-Loop: $ABUSE
# if the string is in the head of a multipart message or anywhere in
# a single-parter, then score supremum to skip last condition
 * 2147483647^0 $ $\spamstring
# if it didn't, force positive score if the string is in first part of a
# multiparter: this will do a very fast nothing on a single-part message
 * 1^0 PART1 ?? $ $\spamstring
 {
         :0fhw # no need to filter that long body just to modify the head
         | formail -I "X-Spam: $spamstring" -I"X-Loop: $ABUSE"

         :0:
         /var/spool/mail/quarantine/spam/${spamfolder:-$spamstring}
 }


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