I've been trying to incorporate Philip's recipe below for days without any luck.
I'm now taking the plunge because I am not sure what action I need to
incorporate.
I have used another recipe which is crazy because it matches almost all incoming
mail be it that they have a M$ Word attachment or not:
I believe the condition I've used isn't perfect, thus the reason for my trying
Philip's recipe.
Is it sane to incorporate my actions below in Philip's???
SUBJECT=`formail -xSubject: \
| sed -e 's/[;\`\\]/ /g' \
| expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'`
FROM=`formail -rt -xTo: \
| sed -e 's/[;\`\\]/ /g' \
| expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'`
:0fw
* B ?? ^[ ]*name=\".*\.doc\"
| (formail -rt -A "Precedence: Deferred" \
-A "X-Loop: wash(_at_)wananchi(_dot_)com" \
-I "From: Odhiambo Washington" \
-I "Subject: Re: $SUBJECT" ; \
echo "Dearest ${FROM}," ; \
echo "I received your mail with the subject <<"${SUBJECT}">>,"; \
echo "but it had a M$ Word attachment that I wasn't able to"; \
echo "view because of Microsoft licensing restrictions." ; \
echo "" ; \
cat /home/wash/.LOG/.hate-ms-doc) | $SENDMAIL -oi -t
:0:
MICROSUCK
BTW those concotions are all 'borrowed' from the list archives ;)
Thank you.
<cut> Philip's recipe below
| ...
| >There is *NO* guarantee that the name= will come from the same mime
| >attachment as the content type previously matched (consider that the file
| >IS multipart) - you may be better off piping mime messages through an
| >external script to parse the MIME chunks individually. No, I don't have
| >any code sitting around to do this, and I'm not about to write it either.
|
| There are ways... Heh heh heh:
|
|
| # This doesn't correctly handle comments in the header fields
| :0
| * ^Mime-Version:[ ]*1\.0
| * ^Content-Type:[ ]*multipart.*;\/.*
| * MATCH ?? boundary[ ]*=[ ]*\/.*
| {
| boundary = $MATCH
|
| # Strip quotes from the boundary. This should handle
| # backslashes, but it doesn't
| :0
| * boundary ?? ^^"\/.*[^"]
| { boundary = $MATCH }
|
| # Regexps for things in the body. We have to handle header
| # field continuations manually, matching on newlines that
| # are followed by whitespace.
| dotstar = ".*(^[ ].*)*"
| ws = "[ ]*(^[ ]+)*"
|
| # Zero or more header fields in the body
| headerfields = "^(.+:$dotstar^)*"
|
| # The header fields whose values we check for name=
| CTDheader = "Content-(Type|Disposition):"
|
| # The actual regexp for matching that header field
| target = "${CTDheader}${dotstar}name${ws}=${dotstar}\.doc
|
| # Look for a boundary, followed by zero or more header
| # fields and the header field value that we're targetting
| :0 B
| * $ ^--$\boundary${headerfields}${target}
| {
| # DO SOMETHING HERE
| }
| }
|
| There are ways to fix both the comment handling and the backslash bugs,
| but they're minor points.
|
|
| Philip Guenther
</cut>
-Wash
--
Odhiambo Washington
Wananchi Online Ltd.,
wash(_at_)wananchi(_dot_)com 1st Flr Loita Hse.
Tel: 254 2 313985 Loita Street.,
Fax: 254 2 313922 PO Box 10286,00100-NAIROBI,KE
Maybe part of loving is learning to let go.
-Fred Savage, "The Wonder Years"
pgpg1C5tAWSpe.pgp
Description: PGP signature