procmail
[Top] [All Lists]

Re: better vacation(1) emulation

1996-10-29 10:29:54
    > I've finally got around to writing a little utility I called "expired"
    > that can be used with procmail/formail to better mimic some versions of
    > the "vacation" program.  In particular
    >      -tN       Change the interval between repeat replies to the
    >                same  sender.   The default is 1 week.  A trailing
    >                s, m, h, d, or w scales  N  to  seconds,  minutes,
    >                hours, days, or weeks respectively.
    > the current method of doing this with "formail -D" means that you need
    > to know the volume of email you get so that the cache size can be
    > adjusted; too small of a cache, people will get daily replies, too
    > large and they'll only get one/month.

Expired sounds useful, and it may be something people will want to keep,
compile, and save away into their PATH.  I've always thought that this
functionality should really be part of formail.  This way, the pipe
from formail to expired would be unecessary.

However, if users with to use the "standard" toolset, there is an
alternative using only "formail", "fgrep", "date", and the usual
Unix file commands.

If you use "fgrep" with a date string against an ASCII cache file, you
can eliminate more than one reply per day.  With variations on the
"date" command, you can choose different periods for the caching.

Here are the essential recipes (from "ackmail.rc" in my procmail
library):

    # Get the best return address without names & comments.
    # This will be the same address we respond to.
    SENDER=`formail -rtzx To:`

    ... # other stuff omitted

        # Check the mail to see if we have replied recently, and if so, if
        # we should reply again
        DATE=`date +'%D'`

        ... # more stuff omitted

        # Check the cache for a recent ack (a successful grep "delivers" the
        # mail)
        LOCKFILE=$ACKS.lock
        :0 Wh
        | fgrep -i -s "$SENDER $DATE" $ACKS

        # Not in the $ACKS file; add it
        JUNK=`(fgrep -i -v "$SENDER" $ACKS ; echo "$SENDER $DATE" ) >$ACKS.new ;
              rm -f $ACKS ; mv $ACKS.new $ACKS `

        # Release the lock
        LOCKFILE

By playing with variations on the "DATE" assignment, you can create
different periods of replies. 

I would *strongly* recommend against anything more frequent than once
per day.

Another feature of "ackmail.rc" is that it provides a feature where, in
conjunction with another recipe file, "commands.rc", users can disable
these auto-acknowledgements themselves, by sending an email with the
subject "disable autoacks".

If you wish to see "ackmail.rc" (and "commands.rc") in its entirety,
send me an email with the subject of "send procmail library", or browse
my web page under the "mail" link.
___________________________________________________________
Alan Stebbens <aks(_at_)sgi(_dot_)com>      http://reality.sgi.com/aks

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