procmail
[Top] [All Lists]

Re: how to check incoming mail per Date field

1995-12-07 16:03:35
Daniel Tocatlian asked,

| I would like to set up my procmailrc to save 
| yesterdays mail to DATE.mbox.  I came up with the
| variable CURRENT_DATE='date +%a, %d %h 19%y'.  Will
| the following sort yesterdays' mail to DATE.mbox?:
| 
| CURRENT_DATE='date +%a, %d %h 19%y'
| MBOX_DATE='date +%y%m%d'
| 
| :0
| * ^Date:.* < CURRENT_DATE
| $MAILDIR/${MBOX_DATE}_mbox

No.  First, your assignments won't work; you need to use backticks, as
below, to get the date program to run and its output assigned to the
variables; using apostrophes as you did just assigns the static text
you wrote to the variables.  This would be the correct syntax:

  CURRENT_DATE=`date +'%a, %d %h 19%y'`
  MBOX_DATE=`date +%y%m%d`

Second, the less-than sign on the condition line will not do a lexical
or numeric comparison there; it will be taken as part of the search text. 

Third, even if the less-than sign did operate that way, would 31 Mar appear
to be less than 1 Apr, given that the later date has both the smaller number
and the alphabetically earlier month?

As to an answer, you left out one piece of critical information; by
"yesterday's mail" do you mean mail that was sent yesterday or mail that
arrived yesterday?  If the former, you'll have a very hard time, as (1)
the Date: field comes in a lot of different formats and (2) you may want to
define "yesterday" according to your own time zone rather than the sender's.
The date of arrival, on the other hand, is easily extracted from the From_
header.  (I frequently use the From_ header's timestamp as a way to make
recipes turn on and off at predetermined times.)

David W. Tamkin    dattier(_at_)wwa(_dot_)com    MCI Mail: 426-1818

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