procmail
[Top] [All Lists]

Autoresponder comments.

2004-11-03 15:12:03
Based on my previous question I've hacked up the rest of a user-controlled
autoresponder.  It is far from complete (I would prefer there be a
challenge/response for the 'add and remove' commands) but is functional.
Users don't have shell access on the mail server so control via mail seems
to be the cleanest method of doing this.

I'll probably end up piping 'command' messages to a seperate shell script
but this is 'functional.'

Anyone have any comments on this implementation?

Some people send 'HTML mail' which really messes up the 'auto response'
and am not sure how to deal with that case (rather than my insistance of
just using plain text).

#cat ~/.procmailrc
# If the Subject contains the 'add command' and is from an 'authorized' user
# copy the body of the message to an autoreply.txt file and deliver a copy
# of the message locally.
:0
* Subject:.*autoreply.*add
* $ 
From:.*($LOGNAME(_at_)domain\(_dot_)com|user_a|user_b(_at_)domain\(_dot_)com)
{
        :0 bc
        | cat > autoreply.txt

        :0
        Maildir/
}

# If the Subject contains the 'remove command' and is from an 'authorized'
# user (ie. assistant/secretary etc.) then remove the autoreply.txt file and
# deliver a copy of the message.
:0
* Subject:.*autoreply.*remove
* 
From:.*($LOGNAME(_at_)domain\(_dot_)com|user_a(_at_)domain\(_dot_)com|user_b(_at_)domain\(_dot_)com)
{
        :0c
        # Not sure how to ignore the input and run the command so send
        # stdin to /dev/null
        | (0>/dev/null && rm $HOME/autoreply.txt)

        :0
        Maildir/
}

# If message is not a 'bounce back', from an internal list or looping send
# the autoreply if the autoreply.txt exists.
# We should continue to have the message also delivered locally.
:0c
*   !^FROM_DAEMON
*   !^From:.*(list_1|list_2|list_3)@domain\.com
* $ !^From:(_dot_)*$LOGNAME(_at_)domain\(_dot_)com
* $ !^X-Loop: $LOGNAME(_at_)$HOST
* $ ?/usr/bin/test -e $HOME/autoreply.txt
| ( formail -rk -A"X-Loop: $LOGNAME(_at_)$HOST"; cat "$HOME/autoreply.txt" ) |
/usr/lib/sendmail -toi

# Default is just to deliver.
:0
Maildir/



-- 
Sean


____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail