procmail
[Top] [All Lists]

Re: handling multiple forwardees

1996-07-27 09:43:14
dattier(_at_)wwa(_dot_)com (David W. Tamkin) wrote:
Here's one way: if there is a comma in an addressee header, or if there are
two or more non-empty addressee headers, we have more than one addressee:

       MULTIPLES
       :0
       * ^TO[a-z].*,.*[a-z]
       { MULTIPLES=yes }
       :0E
       * 1^1 ^TO[a-z]
       * -1^0
       { MULTIPLES=yes }

But remember, it looks for more than one addressee in the headers, not more
than one recipient on the envelope.  There are many circumstances under 
which
the two can differ.

i'd like to make use of this, but i find it can trip up, in particular
for a message directed to me, with a comment that includes a comma:

To: "Brian J. Coan, Political Skeleton" <brian(_at_)igc(_dot_)apc(_dot_)org>

this gets a MULTIPLES=yes value.  any possibility of refining
the match?

This is a Really Hard Problem.  It requires an RFC822 address parser;
RFC822 addresses can be even more convoluted than your example above.

Formail has an RFC822 parser, but currently uses it internally, and
there no current way for the user to extract individual addresses of
an address list.

For example, "formail -rtzxTo:" will extract the "best" address of the
originator of the message, without any annotations, such as commented
text.

But, this "best" address extraction is only available with "-r", where
formail is used to determine a reply address.

-----BEGIN WISHFUL THINKING-----

It would be nice if a new option (say "-l DELIM") to formail were added
to define the address delimiter, used when printing lists of multiple
addresses.  The default DELIM, when no '-l' is given, is ", ", which is
the usual convention (used implicitly).

When -l is given and DELIM is omitted, the default would be "\n" (a
newline) which would causes multiple addresses to be separated by
newlines.  The effect, when extracting multiple addresses, would be
addresses separated by newlines, which is useful for subsequent
processing by awk, perl, or whatever, without more RFC822 parsing.

A delimiter for "pretty" output might be:

    formail -l',\n\t'

which would cause all address lists to look like:

    To: address1,
            address2,
            address3
    Cc: cc-addr1,
            cc-addr2,
            ...
            cc-addrN
    ...

Another option is needed to cause addresses to be "stripped" of their
annotations, say the '-S' option.  This would result in a "bare"
address, without any commented text (text in either quotes or
parentheses).

These options could then be applied like this:

If given input like:

    % cat mail
    To: comics
    Cc: archie, betty "The Blond", veronica (The Rich), jughead (The
        Dumb One), moose "Big and Dumb", reggie (The Crass, Snide One)
    Subject: blah blah

    ...

The following are example outputs:

    % formail -czxCc: <mail
archie, betty "The Blond", veronica (The Rich), jughead (The Dumb One), moose 
"Big and Dumb", reggie (The Crass, Snide One)

    % formail -SczxCc: <mail
archie, betty, veronica, jughead, moose, reggie

    % formail -l -czxCc: <mail
archie
betty "The Blond"
veronica (The Rich)
jughead (The Dumb One)
moose "Big and Dumb"
reggie (The Crass, Snide One)
    
    % formail -l -SczxCc: <mail
archie
betty
veronica
jughead
moose
reggie

This should be an easy feature to add to formail.  I'll look into it.

-----END WISHFUL THINKING-----

Alan

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