procmail
[Top] [All Lists]

Re: Procmail ruleset: what is wrong?

2000-05-11 14:13:28
On 09/05/00 at 11:03am, David W. Tamkin wrote:

OM# | I want to create a recipe that will check for HTML messages and/or
OM# | messages with attachments (of any kind), add a banner -message- before the
OM# | body and then let the message go to normal delivery.
OM# | 
OM# | The recipe I have is not working. It reads as follows:
OM# 
OM# It would help if you would say what is happening instead of what you expect
OM# so that we'd have more detail than "not working."
OM# 
OM# | :0:
OM# | * !^FROM_DAEMON
OM# | * !^From TRC
OM# | * !^majordomo(_at_)bus\(_dot_)ucf\(_dot_)edu
OM# | * !^majordomo-owner(_at_)bus\(_dot_)ucf\(_dot_)edu
OM# | * !^owner-cba(fac|stf|adj)?(_at_)bus\(_dot_)ucf\(_dot_)edu
OM# | * ^Content-Type:\<*text/html
OM# | * ^Content-Type:\<*multipart/(mixed|alternative)
OM# | {
OM# |    :0 fhw
OM# |    | /bin/cat -; /bin/echo "<<< WARNING >>>"; /bin/echo " "
OM# | }
OM# 
OM# I see a number of suboptimal things there, but probably the main reason for
OM# trouble is that you're expecting two matches to Content-Type: of which at 
OM# most one is going to be there: you're ANDing them and I guess you meant to
OM# OR them.
OM# 
OM# Let's revamp this from scratch.  First, there's no reason to ask for a local
OM# lockfile on opening a brace next (unless you're cloning) and there's no
OM# reason to open a brace nest to do one unconditional recipe.  Second, the
OM# "majordomo" and "owner-cba" conditions shouldn't be left-anchored; no 
message
OM# will have those words left-anchored in the head, so no message will ever 
fail
OM# conditions that make sure the impossible didn't happen.  Also, if we take 
the
OM# angle brackets out of $SHELLMETAS (or if you use some other symbol around 
the
OM# word "warning") we can insert the text without invoking a shell.  Moreover,
OM# I believe in setting the PATH variable properly so that other programs can 
be
OM# called by their basenames rather than typing out the absolute path to each
OM# one or cluttering the environment with a variable for the absolute path of
OM# each one, but if you want to specify /bin/sed or /usr/bin/sed (wherever it
OM# lives on your system), go right ahead:
OM# 
OM# savemetas=$SHELLMETAS
OM# SHELLMETAS
OM# 
OM#  :0fhw
OM#  * ! ^FROM_DAEMON
OM#  * ! ^From TRC
OM#  * ! (majordomo(-owner)?|owner-cba(fac|stf|adj)?)@bus\.ucf\.edu
OM#  * ^Content-Type:\<*(text/html|multipart/(mixed|alternative))
OM#  | sed "$ a\\
OM# <<< WARNING >>\\
OM# \\
OM# "
OM# 
OM# SHELLMETAS=$savemetas
OM# 
OM# Your version of sed might not need the extra line of double backslashes.
OM# If you get two blank lines below the word "WARNING" instead of just one,
OM# take the additional line of backslashes out.

Ok, here I come again. I tried the above recipe. Does not work either. The
more detail on the does not work would be that is not doing what is
supposed to. Every email (html or with attachment, or both) pass through
and arrives to the mailbox unchanged. 

I have this recipe given to me by Era that works on HTML emails, but I can
not figure out how to add to check and do the same for attachments. In
other words, I haven't been able to make the changes to adapt it to a new
situation. Here it is, unchanged, as Era send it over:

:0:
* !^FROM_DAEMON
* !^From TRC
* !^majordomo(_at_)bus\(_dot_)ucf\(_dot_)edu
* !^majordomo-owner(_at_)bus\(_dot_)ucf\(_dot_)edu
* !^owner-cba(fac|stf|adj)?(_at_)bus\(_dot_)ucf\(_dot_)edu
{
    :0
    * ! ^Content-Type:\<*text/html
    * ! ^Content-Type:\<*multipart/(mixed|alternative)
    { }

    # Else, if it's a multipart but it doesn't have HTML, do nothing; ...
    :0E
    * ^Content-Type:\<*multipart/(mixed|alternative)
    * ! B ?? ^Content-Type:\<*text/html
    { }

    :0E
    | (/usr/bin/formail -rt ; /bin/cat \
    /admin/d/david/admin/other/nohtml.txt) | /usr/lib/sendmail -oi -t
}


I would like the above to be able to match text/html and/or
multipart/mixed|alternative, add a banner before body and let it go to
normal delivery.

Cheers,


-
David

<Prev in Thread] Current Thread [Next in Thread>