#!/bin/sh
# 
# File: /etc/vmailmgr/vdeliver-postdeliver

export PATH=/bin:/usr/bin

# subject to pre-pend to response, note the space at end
SUBJECT="(Auto-responder) Re: "
ORIGMSG="Your original message follows:"

# max number of reponses sent (per hour) to unique email addy's
NUMBER_RESP=2

# set up email addy's, caught by hacked qmail-autoresponder
VHOST=`basename $HOME`
export VDELIVER_NAME=$VUSER@$VHOST
export VDELIVER_HOST=$VHOST
export VDELIVER_USER=$VUSER

# check that file exists
if [ -f "$HOME/users/$VUSER/autoresponse/message.txt" ]; then 
  qmail-autoresponder -c -o "$ORIGMSG" -n $NUMBER_RESP -s "$SUBJECT" \
      $HOME/users/$VUSER/autoresponse/message.txt \
      $HOME/users/$VUSER/autoresponse
fi

# release env variables
unset VDELIVER_NAME
unset VDELIVER_HOST
unset VDELIVER_USER

