procmail
[Top] [All Lists]

RE: A sightly more elaborate "From" regexp

2001-06-20 10:31:33

At 08:24 2001-06-20 -0400, Colin J. Raven wrote:
At 16:49 2001-06-19 -0400, Colin J. Raven wrote:
>stuff-users-admin(_at_)list(_dot_)stuff(_dot_)com; on behalf of; Brian Brown
>[bbrown(_at_)his_domain(_dot_)com]
>
>  :0
>* ^From: .+@(.+\.)bbrown(_at_)his_domain\(_dot_)com
>/dev/null

I must be missing somthing obvious, but what precisely is wrong with:

* ^From:(_dot_)*bbrown(_at_)his_domain\(_dot_)com

FTR, the attribution and quote indent on your message was FUBAR.

Errr....nothing I guess, :-) but will it pick that address up from the (now
determined to be illegal) From field which already contains another email
address *to the left* as in the following example:

So, it's to the left.  Work out the regexp:

^From:(_dot_)*bbrown(_at_)his_domain\(_dot_)com

^               start at beginning of line
From:           literal match

Okay, these two mean find lines starting with From:, as in the header field by that name.

.*              match any number (including zero) of anything.

bbrown(_at_)his_domain\(_dot_)com
                match this specific text.


What will happen is that the From: line will be found, and in the process of matching bbrown on that line, the .* expression will match everything from just after the colon to just before the address to be matched.

It *WILL* match the line in question, whether that line is RFC compliant or not.

procmail-admin(_at_)Lists(_dot_)RWTH-Aachen(_dot_)DE; on behalf of; 
Professional Software
Engineering [PSE-L(_at_)mail(_dot_)professional(_dot_)org]

<musing> would:
* ^From:(_dot_)*PSEL(_at_)mail(_dot_)\professional\(_dot_)org
 be plucked from that "From" field???

Well, there's a typo (omitted dash in the address), but yea, if the address is there in the line, it'd be matched.

The problem simply stated is this, if it doesn't do it and instead slam
dunks the list traffic I get slammed myself. (not that I'm concerned, but
I'd prefer not to accidentally interrupt traffic)

Your match text isn't "stuff-users-admin(_at_)list(_dot_)stuff(_dot_)com", so why would it smash your regular list messages? It'll only match messages which at least contain the twit's address - though it won't necessarily match only LIST messages containing his address (thus, this SAME rule would match directly addresed messages as well). If you want to match only list messages from him, then you'd add a second ^From check in there with the list address, OR do something like:

* ^From:(_dot_)*stuff-users-admin(_at_)list\(_dot_)stuff\(_dot_)com(_dot_)*on behalf of(_dot_)*bbrown(_at_)his_domain\(_dot_)com

(that's one line)

Chances are, if he's a twit, you don't want to see ANY of his messages, and the basic rule would work just fine.

DOH!!...way to test...put it in my own ~.procmailrc and see what happens!
<slapping self on head for narrow thinking>

Well, if you had concerns about it ditching messages, and if you feel the need to test it on your LIVE mail stream (that which runs through ~/.procmailrc), you should add the 'c' (copy) flag to the rule, and/or rather than filing to /dev/nul, put it in a file you can later rummage through.

For testing, I have a separate rc file called, get this, testing.rc, which is in a directory separate from the rest of my procmail stuff. This does some basic stuff I nearly always use, then includerc's a file 'test_filter.rc', which is where I put small smippets of code in to test. If you save a copy of your mailspool, you can easily feed it into the test script at a later date to see how it works against your mail. Invoke:

        formail -s procmail -m testing.rc < SomeMailboxFileToTest

Follow the URL in my .sig for links - it's nothing elaborate, but it works quite well for running quick tests.

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

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