Notification Events: Possible to set mail headers?

Moderator: crythias

Post Reply
shostakovich
Znuny advanced
Posts: 146
Joined: 11 Apr 2011, 08:11
Znuny Version: 3.2.5

Notification Events: Possible to set mail headers?

Post by shostakovich »

Hi,

we're using customer notifications on new/close tickets. Now, with such mails, we want to trigger an Action on a mail server - but the necessary information should not be visible for the user: i.e. we want to have the Queuename sent as an emails X-header, not within the body. If there's no easy possibility, maybe we'd have to delete the respective line from the body after doing the magic.

Anyone ever accomplished this?

TIA
Michael
MichaelR
Znuny expert
Posts: 250
Joined: 12 Oct 2010, 01:35
Znuny Version: 3.0.9
Company: LRS Health

Re: Notification Events: Possible to set mail headers?

Post by MichaelR »

I've set custom X-headers when sending emails (High Importance & Read-Receipt). It is possible :)
OTRS: 3.0.9 & ITSM 3.0.4 - OS: Windows 7 - DB: MySQL - Heaps of random/useful hacks :)
[Major Code Changes]
ArticleFreeTime1-3
Ability to search ArticleFreeText
shostakovich
Znuny advanced
Posts: 146
Joined: 11 Apr 2011, 08:11
Znuny Version: 3.2.5

Re: Notification Events: Possible to set mail headers?

Post by shostakovich »

MichaelR wrote:I've set custom X-headers when sending emails (High Importance & Read-Receipt). It is possible :)
Well, great :D
[ ] Easily possible, configurable
[ ] Possible
[ ] 100 days of code auditing plus 50 days of implementation

[x] -v:
[____________________________________]
renee
Znuny expert
Posts: 241
Joined: 06 Feb 2009, 11:15
Znuny Version: 3.0.x
Company: Perl-Services.de
Contact:

Re: Notification Events: Possible to set mail headers?

Post by renee »

These mail headers should be set in the customer notification sent from OTRS, right?

Then you have to add a some lines of code in Kernel/System/Email.pm and Kernel/System/Ticket/Event/NotificationEvent.pm:

In Kernel::System::Email:

Code: Select all

for my $HeaderKey ( grep{ m{\AX-} }keys %Param ) {
    $Header{$HeaderKey} = $Param{$HeaderKey};
}
(somewhere near $Header{'X-Mailer'} = "$Product Mail Service ($Version)";)

In Kernel::System::Ticket::Event::NotificationEvent replace

Code: Select all

        $Self->{SendmailObject}->Send(
            From       => $From,
with

Code: Select all

        $Self->{SendmailObject}->Send(
            From       => $From,
            'X-OTRS-Queue' => $Article{Queue},
This code is untested!
Need a Perl/OTRS developer? You can contact me at info@perl-services.de
shostakovich
Znuny advanced
Posts: 146
Joined: 11 Apr 2011, 08:11
Znuny Version: 3.2.5

Re: Notification Events: Possible to set mail headers?

Post by shostakovich »

Thanks... I tested it - unfortunately it does not add a header :o
renee
Znuny expert
Posts: 241
Joined: 06 Feb 2009, 11:15
Znuny Version: 3.0.x
Company: Perl-Services.de
Contact:

Re: Notification Events: Possible to set mail headers?

Post by renee »

It should add a header - I've just tested it. So it is an event notification, isn't it??

I have to look at MIME::Entity why "X-OTRS-TestHeader" is changed to "X-Otrs-Testheader"...
Need a Perl/OTRS developer? You can contact me at info@perl-services.de
MichaelR
Znuny expert
Posts: 250
Joined: 12 Oct 2010, 01:35
Znuny Version: 3.0.9
Company: LRS Health

Re: Notification Events: Possible to set mail headers?

Post by MichaelR »

My method is more hack-job'y but it works fine, I had issues with adding the 'Disposition-Notification-To' header before the MIME:Entity was built, as it was removing/screwing it up.

I have a checkbox in the .dtl that passes a parameter through to Email.pm, and depending on if the checkbox is ticked or not.

Part of my code is:

Code: Select all

if ( defined $Param{Priority} ) {
		$Header->replace('X-Priority', '1');
	} else {
		$Header->replace('X-Priority', '3');
	}
This is performed after the Entity is built.

Code: Select all

my $Entity = MIME::Entity->build( %Header, Data => $Param{Body} );

    # set In-Reply-To and References header
    my $Header = $Entity->head;
It works fine for me and everyone is happy :)
OTRS: 3.0.9 & ITSM 3.0.4 - OS: Windows 7 - DB: MySQL - Heaps of random/useful hacks :)
[Major Code Changes]
ArticleFreeTime1-3
Ability to search ArticleFreeText
Rmack09
Znuny newbie
Posts: 42
Joined: 28 Jan 2011, 15:37
Znuny Version: 3_1_3
Real Name: Mack

Re: Notification Events: Possible to set mail headers?

Post by Rmack09 »

how can I use this with Dynamic Fields?
OTRS Ver. 3.1.3 on Ubuntu 10.04 with MySQL database 5.1.49
Post Reply