procmail
[Top] [All Lists]

Re: Follow: Recipe woes

2003-06-01 10:45:41
Thanks for the reply.  I should have said it earlier, but I'm not calling 
SA from procmail.  I'm gluing SA to Sendmail with a milter, MIMEDefang.  
Because of that I don't have the opportunity to extract the original 
Subject.  Something I *could* do is create a new header with MD that 
contains the original, unaltered Subject.  That's doable I think.

X-Original-Subject: blah blah blah

The actual MD code would be something like

action_add_header("X-Original-Subject", "$Subject");

I may go back and give that a try.  

On Sun, 1 Jun 2003, Professional Software Engineering wrote:

You don't remove it with a regexp per-se - you'd "capture" the content of 
the Subject: line and then rewrite the subject header using formail.  You 
could either capture the text before spamassassin is invoked, or you could 
use a $MATCH construct to match the subject-line text which occurrs after 
the given blob in the subject.

The code that Dallman sent worked.  I don't know why I wasn't using a g
flag in that sed regex.  I used it everywhere else.  *wacks head on desk*  
Nevertheless both of those problems appear to be solved.

Uhm, you have the *ORIGINAL* subject, before SpamAssassin got its mitts on 
it.  Surely it might strike you as useful?

FTR, you _really_ should keep the continued pipes at an indent level past 
the intial delivery pipe.  All that sed stuff is unnneeded - just revise 
your formail invocation:

        | $FORMAIL -I ReSent \
                   -I X-Envelope-To: \

                 -I "Subject: $SUBJECT" \

                   -I X-Scanned-By:

As in, you've got the original pre-SA subject stored in $SUBJECT, why not 
put it to good use.  This eliminates an unnecessary invocation of sed.

I'm not sure I follow.  Actually I think what I wrote about using MD would
change this a bit since I don't have an unaltered $SUBJECT (yet).  Now
that I reread what you wrote, are you suggesting I indent the piped
formail section rather than keeping it inline with the piped sed section?  
Logically that would be easier to read.  I'm not sure why I write my 
recipes that way.  I don't do that in other languages.  I'll change that.  
Thanks

        | sed -e "s/domain1.net/spam-report-domain.com/gi" \
              -e "s/aaa.bbb.ccc.14/555.555.555.555/gi" \
              -e "s/aaa.bbb.ccc.12/555.555.555.555/gi" \
              -e "s/domain2.net/spam-report-domain.com/gi" \
              -e "s/domain3.com/spam-report-domain.com/gi" \

         -e 
"s/((domain1|domain2|domain3)\.com(domain4|domain5)\.net))/spam-report-domain.com/gi"

I could certainly change my sed scripts.  It would probably be the most
efficient way.  I'm not sure if you're suggesting I merge the two filter
sections where I call sed and $FORMAIL.  If that is what you're suggesting
then I can't do it.  The first sed/formail combo strips the header changes
from the spam and doesn't touch the Body.  Otherwise the *zor hashes would
be invalid.  The second calling of sed/formail is what munges the body
text to prevent list washing and disguise the real user that the spam was
originally sent to (among other things).  I have two different things to
do that require slightly different copies of the same spam, hence the
separate filter sections.  I'm not sure if that's what your suggesting or
not though.  I can certainly (and should) reduce the number of sed scripts
(-e) where possible though.  That's a good idea.

I've now added this after the SUBJECT matching:

SUBJECT = "`echo $SUBJECT | sed -e 's/\*\*\*SPAM\*\*\* //g'`"

...and it appears to be working like a champ.

In a few minutes I'll change the first filter section to remove that
invocation of sed altering the Subject and replace it with a formail -I
using my newly cleansed Subject from above.  Once that works I'll change
my sed setup in the second filter section to make it world's more
efficient.

To be honest I'm not sure why I'm calling formail again after the lengthy 
sed invocation to remove the same header lines I removed in the first 
filter section.  Hmm...  I should not be working on these recipes in the 
wee hours of the morning.  I do too many weird things.  I think I'll 
remove that and retest.

I'll also test the X-Original-Subject idea.  It might be a handy thing to 
do.

Ok, I *think* that's it.  I believe I should have all the kinks worked out 
then.  BTW, Sean, I'll try your sandbox approach setup soon.  It looks 
slick.  I need to allot some time to learning how to use it though.  
Soon...

Thanks again for the reply
 Justin



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