I'm trying to use procmail to send all messages for a certain domain to RT (Request Tracker). This is more of a question about the .procmailrc file, though.
Here's my current .procmailrc file:
#Preliminaries
SHELL=/bin/sh #Use the Bourne shell (check your path!)
MAILDIR=${HOME} #First check what your mail directory is!
LOGFILE=${MAILDIR}/procmail.log
LOG="--- Logging ${LOGFILE} for ${LOGNAME}, "
VERBOSE=yes
MAILDOMAIN='rt.mydomain.com'
RT_MAILGATE="/opt/rt3/bin/rt-mailgate"
RT_URL="http://rt.mydomain.com/"
LOGABSTRACT=all
### Trying to process using the rt-mailgate script
:0
{
# the following line extracts the recipient from Received-headers.
# Simply using the To: does not work, as tickets are often created
# by sending a CC/BCC to RT
TO=`formail -c -xReceived: |grep $MAILDOMAIN |sed -e 's/.*for *<*\(.*\)>* *;.*$/\1/'`
QUEUE=`echo $TO| $HOME/get_queue.pl`
ACTION=`echo $TO| $HOME/get_action.pl`
:0 h b w
|/usr/bin/perl $RT_MAILGATE --queue $QUEUE --action $ACTION --url $RT_URL
}
### Upon failure, I want to send back an error message to the user, saying
### "Queue does not exist." I took this code from the procmailex manpage.
:0 Wh: no-queue.lock
{
## Reply if error
* !^FROM_DAEMON
* !^X-Loop: noloop@rt.ncom.com
| formail -rD 8192 no-queue.cache
:0 ehc
|(formail -rI"Precedence: junk" -A"X-Loop: noloop@rt.mydomain.com" ; \
echo "The Queue or Action was invalid."; echo "--" \
) | $SENDMAIL -oi -t
}
Do you see a problem with my .procmailrc file? It works fine if the queue exists, but after that point, it just sends the mail to /var/mail/username. I want to throw away the email and return an error message.