At 10:40 2001-12-05 -0500, Richard G. Ball wrote:
In one of those spam checks I run the body of the message though an
html->text filter but the message I want to deliver is the unfiltered
body. What is the best way to recover the original message body? The
section of the code where the filter gets applied looks like this:
:0
* some condition
{
SOMEVARIABLE=|yourscript
}
This would set the variable, but the message hasn't been _delivered_. The
above would work for something where "yourscript" was a filter program (not
a procmail rule). If you want to modify the message and then use that
modified version within your rules, you might have to do this:
:0
* some condition
{
SOMEVARIABLE=|formail -I "X-Ninny: true"|sed -e
'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'
}
:0D
* SOMEVARIABLE ?? ^X-NINNY: TRUE
someaction
The sed example is merely to demonstrate that the message has been
dramatically changed - we've both added a header and forced the whole
message (including that added header) to all uppercase. The D flag on the
rule that follows the transformation tells procmail to pay attention to
case - thus it *IS* looking for an all uppercase "X-NINNY" header. Note
that it'll match, but the message that gets dumped into someaction is the
_original_ unmodified message (as evidenced by the fact that it isn't all
uppercase and does not contain the additional header).
Yes, doing this means that you'll have to contend with a different syntax
on your spam checking rules. It also means that on very large messages,
procmail will have a second complete copy of it in memory (the modified
version), so I can't tell you how good or miserable this will run on a
massive message, but then, if you expected to have both the original and
the modified version, you've got to expect that you're going to use more
memory...
If you wanted to separate the headers from the body, you'd need to execute
the first rule twice - once with an 'h' flag, and the second time with a
'b' flag, directing the results to SOMEHEADER and SOMEBODY type variables
so that you can manipulate them separatley. The procmail flags for body
and header limitations will be meaningless in the context of the second
filter since you're no longer dealing with an object which procmail
recognizes as the message (and therefore, no header/body distinction).
Alternatley, you could probably make the script which you call ALWAYS
return an error, but still use it to set a variable. I'm unclear on the
specific syntax of how one might accomplish this (I know you'd use 'W' in
the flags, as per 'man procmailrc'), but the above should probably
accomplish what you're trying to do if you adapt your filters to it.
I'm interested to hear what the gurus might suggest.
---
Sean B. Straw / Professional Software Engineering
Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
Please DO NOT carbon me on list replies. I'll get my copy from the list.
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail