procmail
[Top] [All Lists]

first try (was: Re: company-wide vacation system based on procmail)

2001-04-23 03:47:14
On Fri, Apr 20, 2001 at 05:41:29PM +0200, Louis-David Mitterrand wrote:

A client liked so much the little vacation recipe I installed for him
that all his co-workers want to be able to edit, activate, disable their
own vacation reply. That is without ever thouching a procmail recipe of
course.

Here is a first try at a vacation implementation for non-unix users.

To activate her vacation message a user simply sends herself a message
containing the vacation auto-reply with a subject of "vacation on". 

To cancel her auto-reply the user sends herselft a "vacation off"
message.

Are there any blatant errors in this recipe?

Thanks in advance for your comments,


In /etc/procmailrc:

#
LOGFILE=/tmp/procmail.log
VERBOSE=on
XLOOP=$LOGNAME(_at_)$HOST
VAC_MESSAGE=$HOME/.vacation.msg
VAC_CACHE=$HOME/.vacation.cache
VAC_LOCK=$HOME/.vacation.lock
NL="
"

# test if message is to and from the same address and if suject is
# "vacation on" or "vacation off"
:0 
# adressed to a system user
*$ ^TO_$LOGNAME@
# and is from that same user
*$ ^From:.*$LOGNAME@
# has subject containing only "vacation (on|off)"
*  ^Subject: *vacation *\/o(ff|n) *$
# clean out extra space
*  MATCH ?? ()\/o(ff|n)
{
    ACTION=$MATCH
    LOG="ACTION: $ACTION, USER: $LOGNAME, HOME: $HOME $NL"

    :0c
    * ACTION ?? off
        # remove vacation message and cache
    | rm $VAC_MESSAGE $VAC_CACHE
    :0Ebc
        # create vacation message from body
    | cat > $VAC_MESSAGE
        # FIXME: extra newline in output; how to deal with attachements?

        # As confirmation that vacation works the user will receive his own
        # auto-reply from the next recipe
} 


:0
# is there a vacation message for that user?
*$? "test -e $VAC_MESSAGE"
{

        # from procmailex
    :0 Whc: $VAC_LOCK
    # Perform a quick check to see if the mail was addressed (to|cc) us
    *$ ^TO_$\LOGNAME@
    # Don't reply to daemons and mailinglists
    *  !^FROM_DAEMON
    # Mail loops are evil
    *$ !^X-Loop: $XLOOP
    | formail -rD 8192 $VAC_CACHE

        # if the name was not in the cache
    :0 ehc         
    | (formail -rI"Precedence: junk" -A"X-Loop: $XLOOP" ; \
        cat $VAC_MESSAGE ) | $SENDMAIL -oi -t

}

-- 
Louis-David Mitterrand - ldm(_at_)apartia(_dot_)org - http://www.premier.fr
_______________________________________________
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>