Email subject manipulation

Hi,

I need to catch an email before ticket is created, and if the email subject
contains a special substring, like “[closed]”, I need to remove it. So when
the ticket is created and emails are sent to requestors, watchers, etc the
email subject wouldn’t have this substring.

How can I catch the email before Rt creates ticket?

Thanks

Dimitry

Using RT 3.2, you should be able to do this with the RT::MailPlugins
infrastructure.On Tue, Aug 10, 2004 at 08:45:52AM -0700, Dimitry Faynerman wrote:

Hi,

I need to catch an email before ticket is created, and if the email subject
contains a special substring, like “[closed]”, I need to remove it. So when
the ticket is created and emails are sent to requestors, watchers, etc the
email subject wouldn’t have this substring.

How can I catch the email before Rt creates ticket?

Thanks

Dimitry


http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Be sure to check out the RT wiki at http://wiki.bestpractical.com

Thanks, but is it possible to do that in RT 3.0.9?
We cannot migrate to 3.2 nowFrom: Jesse Vincent [mailto:jesse@bestpractical.com]
Sent: Tuesday, August 10, 2004 8:46 AM
To: Dimitry Faynerman
Cc: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] email subject manipulation

Using RT 3.2, you should be able to do this with the RT::MailPlugins
infrastructure.

Hi,

I need to catch an email before ticket is created, and if the email
subject
contains a special substring, like “[closed]”, I need to remove it. So
when
the ticket is created and emails are sent to requestors, watchers, etc the
email subject wouldn’t have this substring.

How can I catch the email before Rt creates ticket?

Thanks

Dimitry


http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Be sure to check out the RT wiki at http://wiki.bestpractical.com

I need to catch an email before ticket is created, and if the email
subject contains a special substring, like “[closed]”, I need to remove
it. So when the ticket is created and emails are sent to requestors,
watchers, etc the email subject wouldn’t have this substring.
[…]
Thanks, but is it possible to do that in RT 3.0.9?
We cannot migrate to 3.2 now

I did this myself by hacking rt-mailgate up a bit, making it read the
headers first into a Mail::Header object, doing the dirty work and only
then passing it on to LWP::UserAgent.

As a start, remove this bit of code:
undef $/;

and further on, replace this:

Read the message in from STDIN

$args{‘message’} = <>;

with something along the lines of this code:
my $hdr = new Mail::Header(*STDIN, Modify => 0, MailFrom => “KEEP”);

undef $/;
my $body = <>;

my $subject = $hdr->get(‘Subject’,0);
if (defined $subject) {
chomp $subject;

# do your evil stuff with $subject here, such as...
$subject =~ s/\[closed\]\s*//g;

$hdr->replace('Subject', $subject,0);

}

… ready to feed it to RT

$args{‘message’} = $hdr->as_string . “\n” . $body;

HTH,

-- Niels.

Thanks! I will try thatFrom: rt-users-bounces@lists.bestpractical.com
[mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Niels Bakker
Sent: Tuesday, August 10, 2004 9:14 AM
To: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] email subject manipulation

I need to catch an email before ticket is created, and if the email
subject contains a special substring, like “[closed]”, I need to remove
it. So when the ticket is created and emails are sent to requestors,
watchers, etc the email subject wouldn’t have this substring.
[…]
Thanks, but is it possible to do that in RT 3.0.9?
We cannot migrate to 3.2 now

I did this myself by hacking rt-mailgate up a bit, making it read the
headers first into a Mail::Header object, doing the dirty work and only
then passing it on to LWP::UserAgent.

As a start, remove this bit of code:
undef $/;

and further on, replace this:

Read the message in from STDIN

$args{‘message’} = <>;

with something along the lines of this code:
my $hdr = new Mail::Header(*STDIN, Modify => 0, MailFrom => “KEEP”);

undef $/;
my $body = <>;

my $subject = $hdr->get(‘Subject’,0);
if (defined $subject) {
chomp $subject;

# do your evil stuff with $subject here, such as...
$subject =~ s/\[closed\]\s*//g;

$hdr->replace('Subject', $subject,0);

}

… ready to feed it to RT

$args{‘message’} = $hdr->as_string . “\n” . $body;

HTH,

-- Niels.

http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Be sure to check out the RT wiki at http://wiki.bestpractical.com

Thanks, but is it possible to do that in RT 3.0.9?

Not without more extensive hacking. I had to retool how some of the
mailgateway worked for 3.2 to support PGP authentication.