procmail
[Top] [All Lists]

Re: original date (again)

2001-09-08 11:26:28
Martin McCarthy <marty(_at_)ancient-scotland(_dot_)co(_dot_)uk> writes:
wrote an email to myself at 18.42, terminated Fetchmail, waited 10 Minuts,
activated Fetchmail again.

-----------------------------------------------------------------------
[..]
Received: from pd9522976.dip.t-dialin.net (HELO localhost.Frankux)
(217.82.41.118)
  by mail.gmx.net (mail06) with SMTP; 8 Sep 2001 16:42:20 -0000

Well if I understand correctly (and I confess that I may not have done
so) this is the line that you want to retain.

Perhaps you can get what you want with a simple recipe like:

 :0 fhw
 * ^\/Received:.*by mail.gmx.net.*
 | formail -i "$MATCH"

It turned out that Courier-IMAP uses the mtime of the message file as
the received date.  So, rather than make that Received: header field
the only one in the message, we need to extract the date from the header
field above, fix up its format, then pass it to the 'touch' command.


        :0
        * ^Received:.*by mail.gmx.net.*;\/[^;]+$
        {
                DATE = $MATCH

                :0
                * DATE ?? ()\/[0-9]+
                { DAY = $MATCH }

                :0
                * DATE ?? ()\/(A(pr|ug)|Dec|Feb|J(an|u[ln])|Ma[ry]|Nov|Oct|Sep)
                { MONTH = $MATCH }

                MON2N ="Jan = 01 Feb = 02 Mar = 03 Apr = 04
                        May = 05 Jun = 06 Jul = 07 Aug = 08
                        Sep = 09 Oct = 10 Nov = 11 Dec = 12"
                :0
                * MON2N ?? $ $MONTH = \/[0-9]+
                { MNUM = $MATCH }

                :0
                * DATE ?? $ $MONTH.*\/[0-9]+
                { YEAR = $MATCH }

                :0
                * DATE ?? ()\/[0-2][0-9]:[0-5][0-9]:[0-6][0-9]
                { TIME = $MATCH }

                :0
                * TIME ?? ^^\/[0-9]+
                { HOUR = $MATCH }

                :0
                * TIME ?? :\/[0-9]+
                { MIN = $MATCH }

                :0
                * TIME ?? :[0-9]+:\/[0-9]+
                { SEC = $MATCH }

                TOUCHTIME = "$YEAR$MNUM$DAY$HOUR$MIN.$SEC"

                # Invoke touch on $LASTFOLDER on exit
                TRAP = 'touch -t $TOUCHTIME $LASTFOLDER'
        }



Philip Guenther
_______________________________________________
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>