FW: Possible to strip rtname from subject in specific cases?

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@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@ngat.com
To: lco@kdna.com
Reply-To: dmh@ngat.com
Subject: dummy

Somewhere the original subject gets lost. Any ideas why?

(I am running RT 3.6.5)

Thanks,

Doro

Hi Doro,

It sounds like the template isn’t getting the original subject line from
$Ticket->Transactions->First->Subject. Try it without stripping the token
and see what happens. Replace

my $Subject = $RT::DisableSubjectToken;

with
my $Subject = '“”;

You can also use
$RT::Logger->debug(“Subject is =$Subject=”);

to log what is happening.

This will help focus the problem area.

Gene

At 05:28 PM 10/31/2007, Dorothea Muecke-Herzberg wrote:

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 = ‘mailto:dtb@dummy.orgdtb@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: mailto:dmh@ngat.comdmh@ngat.com
To: mailto:lco@kdna.comlco@kdna.com
Reply-To: mailto:dmh@ngat.comdmh@ngat.com
Subject: dummy

Somewhere the original subject gets lost. Any ideas why?

(I am running RT 3.6.5)

Thanks,

Doro

Gene LeDuc, GSEC
Security Analyst
San Diego State University