procmail
[Top] [All Lists]

Re: handling multiple forwardees

1996-07-27 16:52:52
Brian Coan had trouble using my suggestion for checking for multiple
addressees:

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

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

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

If Brian were content to have his nickname only in his .signature and take
it out of his From: line, then there would be no comma in the To: line when
people write back.  That would solve it for him, but only for him.

Alan Stebbens has already responded:

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

Exactly.  It is very hard for a straightforward text parser to tell the
difference between a string that is between quotation marks because it
is quoted and a string that is between quotation marks because it is
between quoted strings.  Inside quotation marks almost anything goes,
including characters like commas, angle brackets, and parentheses that
have special meanings outside quotation marks.

There's no way to tell the ^TO and ^TO_ tokens not to stop between quotation
marks or between parentheses.

S> ...  "formail -rtzxTo:" will extract the "best" address of the
S> originator of the message, without any annotations, such as commented
S> text.  ...  This "best" address extraction is only available with "-r",
S> where formail is used to determine a reply address.

One can try to use that, but it has shortcomings as well:

        :0h
        * ! ^Resent-Reply-To:
        recipient=|formail -RTo: Resent-Reply-To: | formail -rzxTo:
        :0Eh
        recipient=|sed -n 's/^To:/From:/p' | formail -rzxTo:

It requires a lot of processes and gives meaningless results, because formail
-r extracts only one return address, even when the Resent-Reply-To: or
Reply-To: header contains more than one (and Stephen has told me he plans to
leave it that way).  So unless there is also a non-empty Cc: header, it will
always say that there is only one addressee.

And my previously posted code could falsely report the *absence* of multiple
addressees in this situation:

        To: (a comma-free comment but no address)
        [and no Cc: header]

Pretty obviously there are multiple addressees there.  After all, if you're
writing to only one person, he or she knows that he or she is receiving the
letter, so why bother taking steps to suppress the list?  So the code I
posted can fail in either direction, and what we really need is a way to
check the envelope.


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