procmail
[Top] [All Lists]

Re: procmail/formail question.

1998-07-23 15:53:21
J. Pratt asked,

| What I have done so far is setup procmail so it automatically responds
| to e-mails sent to me with the subject "Information"..  The response is
| sent with the subject "Re: Information".  What I'm wanting is for the
| auto-response to respond with the subject "Re: [Date] Information".  ie
| "Re: 07-23-98 Information"..  Unfortunately, I cannot seem to figure out
| the proper formail arguments to add to my .procmailrc file.

Easy way, though not the most efficient: in the arguments to formail -rt,
include

  -I"Subject: Re: [`date +'%m-%d-%y'`] Information"

A more efficient way, though harder to code, would be to extract (with
procmail's MATCH facility) the date components from the From_ line (or
from the topmost Received: header if your mail comes without From_ lines).
If you receive many requests in a typical day, I'd suggest doing that.
The code would look something like this if your postmarks are like mine

   MO=mm DAY=dd YR=yy  # defaults in case something fails

   :0D
   * ^^From .* \/(J[au]n|Feb|Ma[ry]|Apr|Jul|Aug|Sep|Oct|Nov|Dec) .*
   { MONTHDAYTIMEYEAR=$MATCH }

   :0
   * MONTHDAYTIMEYEAR ?? ()\/..^^
   { YR=$MATCH }

   :0
   * MONTHDAYTIMEYEAR ?? ^^\/...
   { MONTH=$MATCH }

   monthstring=Jan01Feb02Mar03Apr04May05Jun06Jul07Aug08Sep09Oct10Nov11Dec12

   :0
   * $ monthstring ?? $MONTH\/(0[1-9]|1[012])
   { MO=$MATCH }

   :0
   * $ MONTHDAYTIMEYEAR ?? ^^$MONTH +\/[0-9]+
   { DAY=$MATCH
     
     :0 # pad single-digit dates with a zero
     * DAY ?? ^^.^^
     { DAY=0$DAY }
   }

And then, in the formail -rt recipe, include this argument to formail:

  -I"Subject: Re: [$MO-$DAY-$YR] Information"

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