FW: [rt-users] Possible to strip rtname from subject in specific cases?

Dorothea Muecke-Herzberg dmh at ngat.com
Wed Oct 31 20:28:09 EDT 2007


Thank you all very much for your pointers. I've decided to implement the
SendEmail overlay from Gene, because it seems to give me exactly what I
need.

Gene, I've got it almost working, my only problem is that the original
subject line gets stripped as well, only the prefix part of the subject from
my template gets through.


My template is:
{
  my $ToAddress = 'dtb at dummy.org';
  my $FromAddress = $Ticket->CreatorObj->EmailAddress;
  my $Subject = $RT::DisableSubjectToken;
  $Subject .= 'dummy' . $Ticket->Transactions->First->Subject;
  my $Content = $Ticket->Transactions->First->Content();
  $OUT = "From: $FromAddress\n";
  $OUT .= "To: $ToAddress\n";
  $OUT .= "Reply-To: $FromAddress\n";
  $OUT .= "Subject: $Subject\n\n";
  $OUT .= "$Content\n";
}

SendEmail_Local.pm looks like this:

use strict;
no warnings qw(redefine);

sub SetSubjectToken {
    my $self = shift;
    my $tag  = "[$RT::rtname #" . $self->TicketObj->id . "] ";
    my $sub  = $self->TemplateObj->MIMEObj->head->get('Subject');
    my $no_rt_flag = $RT::DisableSubjectToken if $RT::DisableSubjectToken;

    unless ( $sub =~ /\Q$tag\E/ ) {
        $sub =~ s/(\r\n|\n|\s)/ /gi;
        chomp $sub;

        if ( $no_rt_flag && $sub =~ /^\Q$no_rt_flag\E/ ) {
          $sub =~ s/(\Q$no_rt_flag\E)//;
          $tag = '';
        }
        $self->TemplateObj->MIMEObj->head->replace( 'Subject', $tag . $sub
);
    }
}

1;

And the email header is:

From: dmh at ngat.com
To: lco at kdna.com
Reply-To: dmh at ngat.com
Subject: dummy

Somewhere the original subject gets lost. Any ideas why?

(I am running RT 3.6.5)

Thanks,

Doro



On 01/11/2007, Gene LeDuc wrote:
>
>
> Hi Doro,
>
> I needed a way to strip the ticket info from the subject line also, but
> couldn't find anything within RT that would let me do this.  I ended up
> modifying the SetSubjectToken method of Sendmail.pm so that I could
> selectively turn off the feature that adds the [myrt #1234] token to the
> beginning of the subject.
>
> To disable the "add ticket info" feature, you add a "secret code" to the
> beginning of the subject line in your template.  If the code is there, my
> mod strips it and then sends the e-mail with the original subject line
> unchanged.  If the code isn't there, the subject line gets modified as
> usual.  You set a variable ($DisableSubjectToken) in RT_SiteConfig.pm to
> some random sequence of characters that are not likely to ever show up at
> the beginning of one of your ticket subjects and prepend that variable to
> your subject line in your template when you want to turn off ticket
> stamping.
>
> It may be overkill, but it works great for us and stays out of the way
> unless I need it.  Here's where you can find it:
>
> http://wiki.bestpractical.com/view/SendEmail
>
> The documentation might be a little muddy, so feel free to ask if you
> can't figure it out.
>
> Regards,
> Gene
>
> At 04:11 AM 10/31/2007, Dorothea Muecke-Herzberg wrote:
>
> Previous email to the list brought back to my mind an issue we have. We
> need to send emails to
> another tool from RT and this tool scans the start of the subject line, so
> we need to
> strip rtname from the subject line somehow (or at least move it to the
> end).
> Is there a way to do this?
>
> Doro
>
>
> --
> Gene LeDuc, GSEC
> Security Analyst
> San Diego State University
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20071101/0fcb4210/attachment.htm>


More information about the rt-users mailing list