SendingCommentsDirectlyToATicketWithExim4

From Request Tracker Wiki
Jump to navigation Jump to search

We want to send comments directly to a ticket. As we uses exim4 for our MTA, here's a quick guide.

To send a comment directly to a ticket number, set up an exim router and transport:

rt_router:
  driver = accept
  local_part_prefix = rt-
  transport = rt_transport

rt_transport:
  driver = pipe
  environment = EXTENSION=${local_part}
  command = rt-mailgate --action comment --queue General --extension ticket --url http://rt.xxxx.com


Any email addressed to rt-{TicketID} will be added to that ticket as a comment.

We also use a custome field for work order numbers. Sending comments to a ticket based on a custom field value is a bit more complicated but uses the same framework. Any email sent to wo-{WorkOrderNo} will be handled by this router. First the exim router and transport:

wo_router:
  driver = accept
  local_part_prefix = wo-
  transport = wo_transport

wo_transport:
  driver = pipe
  return_fail_output
  user = rt
  command = /usr/local/bin/rtcat

Notice that we have a shell script intead of rt-mailgate. This is to allow ticket id lookup based on the custom field.

#!/bin/sh

export EXTENSION=`rt ls -i "'CF.{WorkOrderNo}'=${LOCAL_PART}" | sed -e s+^.*/++`
if [[ -z $EXTENSION ]] ; then
    echo "Work Order ${LOCAL_PART} not found"
    exit 1
fi
cat - | rt-mailgate --action comment --queue General --extension ticket --url http://rt.xxxx.com

I tried to give the user some feedback if s/he specifies a work order that doesn't exist. They get back a "delivery failed" message from exim that says the Work Order was not found.

In the transport, we have set the user 'rt'. You can use any user; however that user must have the correct rt credentials in ~/.rtrc:

server http://rt.xxxx.com
user UUU
passwd PPP