At 11:52 2000-11-21 -0500, Scot Kreienkamp wrote:
recipes for 7 different subjects, can I setup a rule to make procmail reject
based on the contents of a text file, so that I can have 1 procmail rule?
Also, any drawbacks?
Drawbacks: you have to spawn another process (more memory and cpu cycles),
and procmail is relying on an external app (grep in this case). Unless
you're working with a marginal system, these aren't issues for concern.
Additionally, there is no per-string regexp capability (I don't believe you
can specify a string in the text file with a regexp, so you can't match
something like "low (toner|printer|fax) prices" as a subject line and have
it interpret that as anything but a static string - I realize here, I use
fgrep, but I believe the same holds true for plain grep as well).
The rule itself is quite simple:
:0
* $? $FORMAIL -xSubject: | $FGREP -i -f $PMDIR/junksubjects.dat
$MAILDIR/junksubjects
You could just as soon /dev/null the delivery too, but don't do that until
you're absolutely, positively sure that the filter is working the way you
want it to.
$FORMAIL points to the formail executable, $FGREP points to a grep (doesn't
have to be fgrep tho for this example), $PMDIR is the procmail dir (where
recipe and other support files are).
This recipe matches for each line in the junksubjects.dat file against the
subject line extracted from the message, so you can provide "key phrase"
material in the file and still match subjects (for instance, a reply to a
message will still trigger a match, as long as the phrase you're matching
against is there).
I use a similar invocation within my antispam rules.
For instance, you could put "VIAGRA" on a line in the junksubject.dat file,
and all messages coming through this rule which have VIAGRA (case
insensitive, as per the flag), will be junked.
Now, if you are talking about using one file to specify subject lines AND
target mailboxes, you'll need to write a support app to compare the subject
and return the proper mailbox in $MATCH somehow. I have no plans to go
that route, esp if it isn't clearly defined that is what you're wanting to
do. If it is just for a handful of recipes, it isn't worth the effort.
[snip - why you don't want to sub to the list]
If you were subbed to the list, you'd see this sort of stuff when people
come up with it, or when someone posts a question that looks relevant to
something you may want to do someday.
---
Please DO NOT carbon me on list replies. I'll get my copy from the list.
Sean B. Straw / Professional Software Engineering
Post Box 2395 / San Rafael, CA 94912-2395
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail