Controlling email submissions

Hi,

I’ve done a quick look through the archives and did not find this, so I
thought I would email the list directly…

Is there a way I can enforce email ticket correspondence so that:

  • All ticket correspondence (either new ticket creations or additional
    correspondence to existing tickets) can only have a subject line of say 5
    chars to max 60 characters (I have some users who right an essay on the
    subject line, and no body in the mail),
  • All ticket correspondence must have content in the body of the email (say
    a minimum of 5 characters and no enforced maximum).

I would like to do one of two things when correspondence doesnt match the
above:

  • Send rejection message back, saying the ticket has not created or the
    correspondence has not been accepted becuase (and the reason),

  • truncate the subject line, and repeat it in full in the body of the
    message, (probably less harmful to users) and accept it, generating the
    normal replies/actions, using the truncated subject line, etc.

Would these be easy to patch into RT? I’m currently on 2.0.8, but planning
on going to 2.0.13 when I get the chance to update it.

Thanks…

Chat with friends online, try MSN Messenger: http://messenger.msn.com

Is there a way I can enforce email ticket correspondence so that:

Right there you’ve got an easy solution. You can run RT through a
pre-filter (procmail), to catch:

  • All ticket correspondence (either new ticket creations or additional
    correspondence to existing tickets) can only have a subject line of say 5
    chars to max 60 characters (I have some users who right an essay on the
    subject line, and no body in the mail),

non-good subject lines. For instance, checking that you can quote a valid
membership name before it hits the ticketing system.

( And whilst on the subject of poor problem descriptions,
http://chroniclesofgeorge.nanc.com/ )

  • All ticket correspondence must have content in the body of the email (say
    a minimum of 5 characters and no enforced maximum).

Oooh, now this is harder with procmail. But, you can do it, with avid
reference to the procmailsc man page:

# Match (hopefully) a subject line between 5 and 60 characters,
# not including leading space, but including space afterwards.
:0
* ! ^Subject:\s+\S.{4,59}
! autoresponder-invalid-subject@example.com

# Decrease the score to -2, then add 1 each time we encounter
# a line with 5 or more characters in it, but not quoting
# characters ('>').
# Run mailgate if our score is over 2 (3 valid lines).
:0 Bh
* -2^0
* 1^1 ^\s*[^>]+\s*\S.{4,}
| rt-mailgate

# Still here?
:0
! autoresponder-nocontent@example.com

Note that I’ve treated this mail as an intellectual exercise, and haven’t
tested the above.

I would like to do one of two things when correspondence doesnt match the
above:

  • Send rejection message back, saying the ticket has not created or the
    correspondence has not been accepted becuase (and the reason),

See procmailex man page on how to create autoresponders.

  • truncate the subject line, and repeat it in full in the body of the
    message, (probably less harmful to users) and accept it, generating the
    normal replies/actions, using the truncated subject line, etc.

Hrm… Tricky. Truncating the subject is not hard, eg:

ORIGSUBJECT=`formail -xSubject:`
SUBJECT=`formail -xSubject: | cut -c 1-60`

# Trim the subject to 60 chars if its over 60 chars
# Original subject gets left in header as Old-Subject:
:0 fhw
* ^Subject:\s+\S.{60,}
| formail -i"Subject: $SUBJECT"

But inserting it into the body of the message is somewhat harder… in
fact (after a few minutes of actually reading the procmail/formail man
pages), you’d be better writing a perl snippet to do this for you instead:

# Filter through a one-line perl snippet to trim the subject
# line if its over 60 chars (we don't bother running if its not
# over 60 chars), and to insert the subject in the body of the
# message.
:0 fhw
* ^Subject:\s+\S.{60,}
| perl -e '$inhead=1;prebod=undef; while(<>){ chomp; if(m/^$/){

$inhead=0; if(defined($prebod)){ print “\n\nOriginal Subject (>60 chars):
$prebod \n”;} } if($inhead && m/^Subject:\s+(\S.{0,59})(.*)$/ ){ print
“Subject: $1\n”; $prebod=$1 . $2; }else{ print “$_\n”; } }’

# Apply other checks, run rt-mailgate

Would these be easy to patch into RT? I’m currently on 2.0.8, but planning
on going to 2.0.13 when I get the chance to update it.

In the RT 2.0.x series, I’d say that you wouldn’t want to do this
pre-acceptance activity in RT itself. In RT 2.1+, where Jesse is looking
at Scrips that run before assiging a ticket number (and thus rejecting a
message then would make sense), doing it in RT would be a sinch.

                         Bruce Campbell                            RIPE
               Systems/Network Engineer                             NCC
             www.ripe.net - PGP562C8B1B                      Operations

( And whilst on the subject of poor problem descriptions,
http://chroniclesofgeorge.nanc.com/ )

I first came across this website about 6 months ago… this is one of
my favorites! Everyone who’s ever done IT support of any kind should
see this site. :slight_smile:

Derek Martin
Lead Network Engineer
ddm@skillsoft.com
(603)324-3000 x516