procmail
[Top] [All Lists]

Re: How to get the senders email address in the perl script where procmail forwarded the mail ?

2007-10-07 15:59:24
On Sun, Oct 07, 2007 at 03:59:39PM -0600, LuKreme wrote:

   :0
   * $ ^From:$WS+\/[^$WS]+
   { FROM=$MATCH }

That will not work, presuming that WS is set to a space and a
tab, for two different reasons.  You wanted to write:

     * $ ^From:[$WS]+\/[^$WS].*

Not the ".*" at the end instead of "+", and note the difference
(brackets) before the match token as well.

However, that, too, is not ideal, for two reasons.
1) It is perfectly legitimate to have no whitespace after the
   colon; and
2) It is, anyway, superfluous to have the [$WS] there; the following
   has exactly the same result:

     * $ ^From:.*\/[^$WS].*
    

I believe we had this same round of exchanges about half-a-year ago
or something, by the way, Kreemey.


or

   :0 h
   FROM=|formail -IReply-To: -rtzxTo:

Depending on what, exactly, you want.  The latter is the bare address  
without any label/comment.


Yes, but aside from your comment, this way is not at all equivalent
to having matched what was in the From: header.  It is more likely
to be equivalent to what was in the Reply-To: header; but it's not the
same as that, either.  What it will return is dependent on the
existence, or their lack, of headers such as Sender: and so on.


Here is some relevant text from a Nov. 21, 2002, message to the list by
Philip Guenther:

pg> There is no rfc for formail's behavior [with the -r switch].
pg> It uses an order derived from rules in rfc2822/822, plus some
pg> practical and historical considerations.  The actual orders
pg> are---as of 3.14---as follows, from most preferred to least
pg> preferred:
pg>
pg> formail -r: (envelope sender)
pg>     "From "
pg>     Return-Path:
pg>     Errors-To:
pg>     Return-Receipt-To:
pg>     Path:
pg>     Resent-Sender:
pg>     Resent-From:
pg>     Resent-Reply-To:
pg>     Sender:
pg>     From:
pg>     Reply-To:
pg>
pg> formail -rt:        (header sender)
pg>     Reply-To:
pg>     From:
pg>     Sender:
pg>     Return-Path:
pg>     "From "
pg>     Errors-To:
pg>     Return-Receipt-To:
pg>     Path:
pg>     Resent-Sender: Resent-From: Resent-Reply-To:    (same weight)
pg>
pg> The latter is actually encoded in the source as a bar graph; take a look
pg> at src/formail.c, line 60 or so.

-- 
dman
____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail