How to read custom email headers

I’m trying to read an email address from a custom header I created and
assign that variable as a ticket cc.

I have RT pulling addresses from the From:, and Cc: fields in the
header, but I want it to pull an address from a custom header (ie.
X-Custom: joe@somewhere.com).

I have been testing some custom script actions to try and read the
header, but as of yet have been unsuccessful.

I looked through the wiki, and historic rt-users lists, but didn’t find
anything that helped much.

I got this to work once on RT3.4 by manually changing the source code (I
think it was the Notify.pm script) but can’t seem to find documentation
on that.

This time around, with RT3.6 I would like to do this with custom script
actions, that seems to be the “cleanest” way to do it.

Here is some of my bumbling so far, I’m trying to tackle the reading
portion first:

The header field is “X-Isp:”

Condition: On Create

Action: User Defined

Cleanup Code:

my $MIMEObj = $self->TemplateObj->MIMEObj;

my $isp = $MIMEObj->head->get(‘X-Isp’);

$RT::Logger->notice($isp. " <-- this is X-ISP.\n");

return 1;

This yields me an error in the rt.log:

Commit failed: Can’t call method “head” on an undefined value at (eval
475) line 3.

I’m not sure if there is some additional functions library I need to
include that is not in General.pm, but with my limited knowledge of perl
I’m having a hard time getting through this.

Jon Scheidell

Security Engineer

Secnap Network Security

(561) 999-5000 x:4110

I’m trying to read an email address from a custom header I created
and
assign that variable as a ticket cc.

I believe you’re looking for ExtractCustomFieldValues. You’ll find it
in the ScripActions section at:

http://wiki.bestpractical.com/index.cgi?Contributions

-Tim

Tim Wilson, Director of Technology
Buffalo-Hanover-Montrose Schools
214 1st Ave NE Buffalo, MN 55313
ph: 763.682.8740 fax: 763.682.8743 http://www.buffalo.k12.mn.us

my $attachment = $self->TransactionObj->Attachments->First;
my $isp = $attachment->GetHeader(‘X-ISP’);
I think this should work.On 12/27/06, Jonathan Scheidell jscheidell@secnap.net wrote:

I’m trying to read an email address from a custom header I created and
assign that variable as a ticket cc.

I have RT pulling addresses from the From:, and Cc: fields in the header,
but I want it to pull an address from a custom header (ie. X-Custom:
joe@somewhere.com).

I have been testing some custom script actions to try and read the header,
but as of yet have been unsuccessful.

I looked through the wiki, and historic rt-users lists, but didn’t find
anything that helped much.

I got this to work once on RT3.4 by manually changing the source code (I
think it was the Notify.pm script) but can’t seem to find documentation on
that.

This time around, with RT3.6 I would like to do this with custom script
actions, that seems to be the “cleanest” way to do it.

Here is some of my bumbling so far, I’m trying to tackle the reading portion
first:

The header field is “X-Isp:”

Condition: On Create

Action: User Defined

Cleanup Code:

my $MIMEObj = $self->TemplateObj->MIMEObj;

my $isp = $MIMEObj->head->get(‘X-Isp’);

$RT::Logger->notice($isp. " ← this is X-ISP.\n");

return 1;

This yields me an error in the rt.log:

Commit failed: Can’t call method “head” on an undefined value at (eval 475)
line 3.

I’m not sure if there is some additional functions library I need to include
that is not in General.pm, but with my limited knowledge of perl I’m having
a hard time getting through this.

Jon Scheidell

Security Engineer

Secnap Network Security

(561) 999-5000 x:4110

www.secnap.com


The rt-users Archives

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Best regards, Ruslan.

Thanks!!

That worked perfect

I added some logging to the script action.

[Wed Dec 27 19:56:34 2006] [notice]: joe@blow.com ← this is X-ISP.

Jon Scheidell
Security Engineer
Secnap Network Security
(561) 999-5000 x:4110
www.secnap.comFrom: Ruslan Zakirov [mailto:ruslan.zakirov@gmail.com]
Sent: Wednesday, December 27, 2006 2:50 PM
To: Jonathan Scheidell
Cc: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] How to read custom email headers

my $attachment = $self->TransactionObj->Attachments->First;
my $isp = $attachment->GetHeader(‘X-ISP’);
I think this should work.

I’m trying to read an email address from a custom header I created and
assign that variable as a ticket cc.

I have RT pulling addresses from the From:, and Cc: fields in the
header,
but I want it to pull an address from a custom header (ie. X-Custom:
joe@somewhere.com).

I have been testing some custom script actions to try and read the
header,
but as of yet have been unsuccessful.

I looked through the wiki, and historic rt-users lists, but didn’t
find
anything that helped much.

I got this to work once on RT3.4 by manually changing the source code
(I
think it was the Notify.pm script) but can’t seem to find
documentation on
that.

This time around, with RT3.6 I would like to do this with custom
script
actions, that seems to be the “cleanest” way to do it.

Here is some of my bumbling so far, I’m trying to tackle the reading
portion
first:

The header field is “X-Isp:”

Condition: On Create

Action: User Defined

Cleanup Code:

my $MIMEObj = $self->TemplateObj->MIMEObj;

my $isp = $MIMEObj->head->get(‘X-Isp’);

$RT::Logger->notice($isp. " ← this is X-ISP.\n");

return 1;

This yields me an error in the rt.log:

Commit failed: Can’t call method “head” on an undefined value at (eval

line 3.

I’m not sure if there is some additional functions library I need to
include
that is not in General.pm, but with my limited knowledge of perl I’m
having
a hard time getting through this.

Jon Scheidell

Security Engineer

Secnap Network Security

(561) 999-5000 x:4110

www.secnap.com


The rt-users Archives

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Best regards, Ruslan.