[rt-users] email subject manipulation
Dimitry Faynerman
dimitry.faynerman at hypermediasystems.com
Tue Aug 10 12:25:00 EDT 2004
Thanks! I will try that
-----Original Message-----
From: rt-users-bounces at lists.bestpractical.com
[mailto:rt-users-bounces at lists.bestpractical.com] On Behalf Of Niels Bakker
Sent: Tuesday, August 10, 2004 9:14 AM
To: rt-users at lists.bestpractical.com
Subject: Re: [rt-users] email subject manipulation
* dimitry.faynerman at hypermediasystems.com (Dimitry Faynerman) [Tue 10 Aug
2004, 17:58 CEST]:
>>> 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
More information about the rt-users
mailing list