procmail
[Top] [All Lists]

date matching problem still

2003-12-11 08:09:18

I have a recipe which doesn't work as I expected (I'm sure it's my fault).
I ran it through my play setup, but I don't understand WHY it didn't work.

Here are the message headers:

From campbell(_at_)starbase(_dot_)neosoft(_dot_)com  Mon Jun 11 08:54:50 2001
Return-Path: <campbell(_at_)starbase(_dot_)neosoft(_dot_)com>
Received: from starbase.neosoft.com (starbase.neosoft.com [206.109.1.32])
        by helium.inexs.com (8.9.3/8.9.3) with ESMTP id IAA19196
        for <campbell(_at_)[63(_dot_)140(_dot_)126(_dot_)166]>; Mon, 11 Jun 
2001 08:54:49 -0500
Received: (from campbell(_at_)localhost)
        by starbase.neosoft.com (8.9.3/8.9.3) id XAA08716
        for campbell(_at_)[63(_dot_)140(_dot_)126(_dot_)166]; Sat, 9 Jun 2001 
23:59:03 -0500 (CDT)
        (envelope-from campbell)
Received: from mail3.iadfw.net (mail3.iadfw.net [209.196.123.3])
        by starbase.neosoft.com (8.9.3/8.9.3) with SMTP id XAA08713
        for <campbell(_at_)starbase(_dot_)neosoft(_dot_)com>; Sat, 9 Jun 2001 
23:59:02 -0500 (CDT
)
        (envelope-from bounce-911-541(_at_)rennlist(_dot_)org)
Received: from mx2.airmail.net from [209.196.77.99] by mail3.iadfw.net 
        (/\##/\ Smail3.1.30.16 #30.25) with esmtp for 
<campbell(_at_)neosoft(_dot_)com> sen
der: <bounce-911-541(_at_)rennlist(_dot_)org>
        id <mO/158x4v-00384kO(_at_)mail3(_dot_)iadfw(_dot_)net>; Sat, 9 Jun 
2001 23:43:57 -0500 (
CDT)
Received: from 64-205-178-75.client.dsl.net ([64.205.178.75] helo=rennlist.rennl
ist.org)
        by mx2.airmail.net with smtp (Exim 3.16 #10)
        id 158x5D-000Ao1-00
        for campbell(_at_)neosoft(_dot_)com; Sat, 09 Jun 2001 23:44:15 -0500
Message-ID: 
<LYRIS-541-47141-2001(_dot_)06(_dot_)10-00(_dot_)24(_dot_)15--campbell#neosoft(_dot_)com(_at_)rennlist(_dot_)
org>
Reply-To: c123666(_at_)earthlink(_dot_)net
From: "Carl Cobb" <c123666(_at_)earthlink(_dot_)net>
To: "911/993/996" <911(_at_)rennlist(_dot_)org>
Date: Fri, 4 Jan 1980 01:51:56 -0800
MIME-Version: 1.0
Content-Type: text/plain;
        charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 4.72.2106.4
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4
List-Unsubscribe: <mailto:leave-911-541E(_at_)rennlist(_dot_)org>
Subject: Re: chip in 964 c4..more
Status: RO
Content-Length: 2543
Lines: 83


Here is my recipe (.rc file, with nonpertinent bits removed):

NL="
"
VERBOSE=on
WEEKDAYS = '(S(un|at)|Mon|T(ue|hu)|Wed|Fri)'
MONTHS = '(J(an|u[ln])|Feb|Ma[ry]|A(pr|ug)|Sep|Oct|Nov|Dec)'
WHICH_RECVD = 'by helium.inexs.com'
YEARS = '(19[8-9][0-9]200[0-4])'
TIMESTAMP = '([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]'
GMTOFFSET = '(+|-)[0-2][0-4][0-9][0-9]'
TIMEZONE = '([A-Z][D|S|M]T)'
RCVD_STAMP = "$WEEKDAYS, [0-9]+ $MONTHS $YEARS $TIMESTAMP"

# <space><tab> in [character class] below
:0
* ^Return-Path:[        ]*<\/[^>]*>
* MATCH ?? ^^\/[^>]*
{ RETURNPATH = "${MATCH:-MAILER-DAEMON}" }

LOG=$RETURNPATH$NL

# Get the date from the right received header
# (in this case when the message hit my mailserver vi a fetchmail)
:0
* $ ^Received:.*$WHICH_RECVD.*\/$RCVD_STAMP
{ xDATE = "$MATCH" }

LOG=$xDATE$NL

# short-circuit w/o data
:0fw
* 1^0 RETURNPATH ?? ^^^^
* 1^0 xDATE ?? ^^^^
| formail -i"X-Date-Munge: FAILED"

# If we didn't bail out early...
:0 E
{
    # Build the new "From " header by extracting the date
    # in the right order from xDate

    # From: Sun, 02 Mar 2003 08:29:12
    # To:   Sun Mar 2 08:29:12 2003
    :0
    * $ xDATE ?? ^^\/$WEEKDAYS
    { ENVELOPE = "$RETURNPATH  $MATCH" }
LOG=$ENVELOPE$NL
    :0
    * $ xDATE ?? ^^$WEEKDAYS, [0-9]+ \/$MONTHS
    { ENVELOPE = "$ENVELOPE $MATCH" }
LOG=$ENVELOPE$NL
    :0
    * $ xDATE ?? ^^$WEEKDAYS, \/[0-9]+
    { ENVELOPE = "$ENVELOPE $MATCH" }
LOG=$ENVELOPE$NL
    :0
    * $ xDATE ?? ()\/$TIMESTAMP
    { ENVELOPE = "$ENVELOPE $MATCH" }
LOG=$ENVELOPE$NL

    :0
    * $ xDATE ?? $MONTHS \/$YEARS
    { ENVELOPE = "$ENVELOPE $MATCH" }
LOG=$ENVELOPE$NL

#    # Make sure the $ENVELOPE matches the desired format
#    # If it does, rewrite the From_
#    :0 fhw
#    * $ ENVELOPE ?? $WEEKDAYS $MONTHS [0-9]+ $TIMESTAMP $YEARS^^
#    | sed "s,^\(From \).*,\1$ENVELOPE,"
#        # And add a header showing we've altered the message
#        :0 afw
#        | formail -i"X-Date-Munge: SUCCESS"
#
#        # Otherwise, show that the attempt failed.
#        :0 efw
#        | formail -i"X-Date-Munge: FAILED"
}
LOG=$ENVELOPE$NL


:0:
* < 256000
date_out


Here is the log file entry for this message:

procmail: [31523] Wed Dec 10 11:41:04 2003
procmail: Assigning "WEEKDAYS=(S(un|at)|Mon|T(ue|hu)|Wed|Fri)"
procmail: Assigning "MONTHS=(J(an|u[ln])|Feb|Ma[ry]|A(pr|ug)|Sep|Oct|Nov|Dec)"
procmail: Assigning "WHICH_RECVD=by helium.inexs.com"
procmail: Assigning "YEARS=(19[8-9][0-9]200[0-4])"
procmail: Assigning "TIMESTAMP=([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]"
procmail: Assigning "GMTOFFSET=(+|-)[0-2][0-4][0-9][0-9]"
procmail: Assigning "TIMEZONE=([A-Z][D|S|M]T)"
procmail: Assigning "RCVD_STAMP=(S(un|at)|Mon|T(ue|hu)|Wed|Fri), [0-9]+ (J(an|u[
ln])|Feb|Ma[ry]|A(pr|ug)|Sep|Oct|Nov|Dec) (19[8-9][0-9]200[0-4]) ([01][0-9]|2[0-
3]):[0-5][0-9]:[0-5][0-9]"
procmail: Assigning "MATCH="
procmail: Matched "campbell(_at_)starbase(_dot_)neosoft(_dot_)com>"
procmail: Match on "^Return-Path:[      ]*<\/[^>]*>"
procmail: Matched "campbell(_at_)starbase(_dot_)neosoft(_dot_)com"
procmail: Match on "^^\/[^>]*"
procmail: Assigning "RETURNPATH=campbell(_at_)starbase(_dot_)neosoft(_dot_)com"
procmail: Assigning "LOG=campbell(_at_)starbase(_dot_)neosoft(_dot_)com
"
campbell(_at_)starbase(_dot_)neosoft(_dot_)com
procmail: No match on "^Received:.*by helium.inexs.com.*\/(S(un|at)|Mon|T(ue|hu)
|Wed|Fri), [0-9]+ (J(an|u[ln])|Feb|Ma[ry]|A(pr|ug)|Sep|Oct|Nov|Dec) (19[8-9][0-9
]200[0-4]) ([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]"
procmail: Assigning "LOG=
"

procmail: Score:       0       0 "^^^^"
procmail: Score:       1       1 "^^^^"
procmail: Executing "formail,-iX-Date-Munge: FAILED"
procmail: Assigning "LOG=
"

procmail: Match on "< 256000"
procmail: Locking "date_out.lock"
procmail: Assigning "LASTFOLDER=date_out"
procmail: Opening "date_out"
procmail: Acquiring kernel-lock
procmail: [31523] Wed Dec 10 11:41:05 2003
procmail: Unlocking "date_out.lock"
From campbell(_at_)starbase(_dot_)neosoft(_dot_)com  Mon Jun 11 08:54:50 2001
 Subject: Re: chip in 964 c4..more
  Folder: date_out
-- 

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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