procmail
[Top] [All Lists]

Re: Detecting multiple To: headers?

1999-06-02 10:49:12
Hi,

Is there a easy way to detect number of recipients of a message? I.e. It
should detect there are 5 recipients in the following message:


  From: Doe John <doe(_at_)some(_dot_)edu>
  To: Person1  <person1(_at_)some(_dot_)com>, "Person2 LastName" 
<person2(_at_)some(_dot_)edu>
  cc: Person3 <person3(_at_)some(_dot_)com>,
      Person4 <person4(_at_)some(_dot_)com>,
      Person5 <person5(_at_)some(_dot_)com>
  Subject: Re: Welcome to our list!

Thanks.

Tony

* "D" == David W Tamkin <dattier(_at_)Mcs(_dot_)Net> writes:

D> John Conover asked,
C> So, what would the recipe be to detect multiple To: headers?

D>  :0 # flags and local lockfile if needed by action
D>  * -1^0
D>  * 1^1 ^To:
D>  action_in_case_of_multiple_To:_headers

D> Justin Lloyd had answered,

L> Same as before, except with the fix to the -1 scoring:

L> :0
L> * -1^0
L> *  1^1 ^To:
L> { LOG = "There were $= To: lines." }

D> That will operate on the right occasions but it will log erroneous informa-
D> tion.  With a message with five To: lines, it will say there are four.

D> These will be accurate:

D>  :0 # caution, this reports "1" for normal mail with one To: header
D>  * 1^1 ^To:
D>  { LOG="There are $= To: lines.
D> " }

D> or

D>  :0
D>  * -1^0
D>  * 1^1 ^To:
D>  { LOG="There are $= extra To: lines.
D> " }

D> or to log the full count but only if there are two or more,

D>  :0
D>  * -1^0
D>  * 1^1 ^To:
D>  { }
D>  :0A
D>  * $ $=^0
D>  * 1^0
D>  { LOG="There are $= To: lines.
D> " }

D> or the Philip Guenther way,

D>  :0
D>  * -1^0
D>  * 1^1 ^To:
D>  * - 2147483647^0
D>  * 2147483648^0
D>  { LOG="There are $= To: lines.
D> " }

-- 
tony