procmail
[Top] [All Lists]

Re: scored weighting, and aborting questions.

1997-01-12 15:52:58
Ken Marsh asked,

| 1.) I read the entire procmailsc man page. While there is a lot
| about  putting together rules, the actual acceptance criteria
| is NOT listed! Is it a score that is positive, or negative,
| or over a certain value?

A recipe's conditions have passed (and its action will be executed) if
(1) all unweighted conditions are met; and
(2) the total score of all weighted conditions is POSITIVE.

A zero total or a negative total is a failure, and procmail will move on
to the next recipe or assignment.

[There are two special cases: if the score reaches supremum (+2,147,483,647)
 the score is deemed passed and remaining weighted conditions are ignored. 
 (Remaining *unweighted* conditions are still tested and must pass.)  If the
 score reaches infemum (-2,147,483,647) then the score is deemed hopelessly
 negative and procmail jumps ahead to the next recipe or assignment.]

| Can I set that value?

Not exactly.  If you want to say that it takes more than ten points for the
recipe to pass, though, you can add this condition:

   * -10^0

A blank condition always matches, so a weight on it always affects the score.
That lowers the score by 10, so now the rest of the addends in the score have
to exceed ten for the final score to exceed zero and for the recipe to pass.

If you want it to take ten points to pass and still pass on ten points
exactly, it's almost as easy.  If you're dealing only in whole points and
not in any fractions,

   * -9.9^0

If you are dealing in fractional points in the other conditions, then just
make sure that the flat subtraction is closer to 10 than the finest fraction
in the other conditions.  For example, if the other conditions have scores
that are as fine as 1/1000 of a point, and 9.999 is failing but 10 is
passing,

  * -9.9999^0

will do the trick.

| How would I use the $= withing procmail (or would I have  to
| pass it to another program) to use it's value?

Actually, passing it to another program is rarely useful.  $= is good
for saving a score from recipe to recipe.  To add $= to the score of the
next recipe,

   * $ $=^0

If you want to use it later than the very next recipe, save it in a named
variable: 

  SAVED_SCORE = $=

and later,

  * $ $SAVED_SCORE^0

| 2.) I tried LOG="I received a letter" placed in part of
| a rule, to update the logs when a certain non-delivery rule
| is invocked. It then places the letter in a file named, joy
| of joys, 'LOG=I received a letter'. How can I make it
| USE the LOG command instead of file into it?

You're forgetting the braces, I'll wager.  An assignment cannot be the
action line of a recipe, but a left brace can.  Try this:

  :0 flags
  * conditions
  { LOG="I received a letter.
" }

Remember that if you want a newline in the log after the text you assign
to $LOG, you must include it specifically in the assignment.

| 3.) In the same fashion, how to I get it to ABORT or 
| INTERRUPT in a rule, rather than put it in a file
| name "INTERRUPT"? If the letter is forged, will sendmail
| (not using procmail as the default delivery agent in this case)
| bounce it correctly to the originator? If procmail is the
| default senmail delivery agent, will it bounce it correctly
| then on an ABORT?

That depends on exactly what you want to occur on "ABORT" or "INTERRUPT".
If you want just to bit-bucket the incoming message, save it to /dev/null
or, in most situations, unset or mis-assign the HOST variable.

| 4.) How would I put together a rule to bounce email sent to
| 20 or more addresses? So far I have:
|  :0h
|  * 1^1 @
|  (and then something like) if $= > 20
|  ABORT (or whatever)

First, I would not recommend counting every @ in the head, because there
will be some in Return-Path:, From:, Reply-To:, Message-Id:, and such other
places.  It will also fail to count unqualified local addresses and
recipients of blind carbons.  But if the idea is that more than twenty
points are needed to execute the action,

  * -20^0

will, as I explained above, subtract twenty from the score.