nick: October 2011 Archives

Mutt and request tracker

| | Comments (0)

Here is a perl script I wrote to take an email from mutt and close it in request tracker:


#!/usr/bin/perl

use warnings;
use strict;

use Mail::Sendmail;

my ($replyto, $replyfrom, $subject, $queue, $rthost, $isaticket);

#it must be from the address RT thinks you have
$replyfrom="nick\@prgmr.com";

while (<STDIN>) {
        chomp $_;
        if (/^Reply-To: (.@.)$/) {$replyto=$1;}
        if (/^RT-Ticket:/) {$isaticket="true";}
        if (/^Subject: (.)$/) {$subject=$1;}
}

if($isaticket) {
        if ($replyto=~/^(.)(-comment){0}@(.*)$/) {
                $queue=$1;
                $rthost=$3;
        }
}
else {
        print "Not a ticket.\n";
        exit(1);
}

my %mail=(
        server => 'localhost',
        from => $replyfrom,
        to => "$queue-comment\@$rthost",
        subject => $subject,
        body => 'Status: resolved',
);

sendmail(%mail) or die $Mail::Sendmail::error;
exit(0);

About this Archive

This page is a archive of recent entries written by nick in October 2011.

nick: January 2009 is the previous archive.

Find recent content on the main index or look in the archives to find all content.