[SOLVED] OTRS against mail repeated

Moderator: crythias

Locked
klausneil
Znuny superhero
Posts: 682
Joined: 29 May 2012, 22:47
Znuny Version: 6.0.24
Real Name: Klaus Salazar
Location: Perú

[SOLVED] OTRS against mail repeated

Post by klausneil »

Hi i have a little question, is if anybody send 10 email with the same content (the address is valid), seems absurd but if it did, that action could be taken in this case? thank you very much.
Last edited by klausneil on 30 Nov 2012, 17:48, edited 1 time in total.
Wolfgangf
Znuny ninja
Posts: 1029
Joined: 13 Apr 2009, 12:26
Znuny Version: 6.0.13
Real Name: Wolfgang Fürtbauer
Company: PBS Logitek GmbH
Location: Pinsdorf

Re: OTRS against mail repeated

Post by Wolfgangf »

you'll want to "Merge to oldest ..." these tickets on the GUI with Bulk action in Queue view
Produktiv:
OTRS 6.0.13/ ITSM 6.0.13
OS: SUSE Linux (SLES 12, Leap), MySql 5.5.x, 5.6.x
Windows 2012 AD Integration (agents and customers), Nagios integration (incidents, CMDB), Survey, TimeAccounting
klausneil
Znuny superhero
Posts: 682
Joined: 29 May 2012, 22:47
Znuny Version: 6.0.24
Real Name: Klaus Salazar
Location: Perú

Re: OTRS against mail repeated

Post by klausneil »

Hi i dont understart, but i want that otrs deny the reception of email repeated with the same content.
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: OTRS against mail repeated

Post by jojo »

thats not possible
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: OTRS against mail repeated

Post by reneeb »

You have to write an postmaster filter that checks for "doubled" content and sets the "X-OTRS-Ignore" flag to "yes". But is this really what you want? Are you sure that it's impossible that two mails with same content are valid (e.g. system monitoring can send mails with same content or users that fill some webforms or ...)?
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
klausneil
Znuny superhero
Posts: 682
Joined: 29 May 2012, 22:47
Znuny Version: 6.0.24
Real Name: Klaus Salazar
Location: Perú

Re: OTRS against mail repeated

Post by klausneil »

Is perfect. thanks, yes this is really it what wanted, I spend a case that a customer sent an email and when get 6 email duplicates, even so many thanks for the idea I will implement it. regards.
klausneil
Znuny superhero
Posts: 682
Joined: 29 May 2012, 22:47
Znuny Version: 6.0.24
Real Name: Klaus Salazar
Location: Perú

Re: OTRS against mail repeated

Post by klausneil »

Hi reneeb today I did a test but I lack a condition could give me a help, attached to the image. thank you very much
01.png
You do not have the required permissions to view the files attached to this post.
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: OTRS against mail repeated

Post by reneeb »

Hi klausneil,

it's not possible to check for doubled content with such Postmaster filters. You have to write an Perl module and enable the filter in your config (see http://doc.otrs.org/3.1/en/html/email-r ... ing-filter)
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
klausneil
Znuny superhero
Posts: 682
Joined: 29 May 2012, 22:47
Znuny Version: 6.0.24
Real Name: Klaus Salazar
Location: Perú

Re: OTRS against mail repeated

Post by klausneil »

Hi i don't understand, first you tell me to do a postmaster filter and now you tell me that's not possible?
reneeb wrote:You have to write an postmaster filter that checks for "doubled" content and sets the "X-OTRS-Ignore" flag to "yes". But is this really what you want? Are you sure that it's impossible that two mails with same content are valid (e.g. system monitoring can send mails with same content or users that fill some webforms or ...)?
I just want to block this type of delivery mail
100.png
You do not have the required permissions to view the files attached to this post.
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: OTRS against mail repeated

Post by jojo »

rene already mentioned that you need to "write" a postmaster filter. Which means that you need to develop this kind of filter. It is not possible to do yo via GUI
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: OTRS against mail repeated

Post by reneeb »

There are two "types" of postmaster filters. Those created via the GUI (Admin area -> PostMaster Filters) and those that are Perl modules.

The filter you need looks like this:

Code: Select all

# --
# Kernel/System/PostMaster/Filter/RejectDoubledContent.pm - sub part of PostMaster.pm
# Copyright (C) 2012 Perl-Services.de
# --
# $Id: NewTicketReject.pm,v 1.20 2012/11/20 15:52:12 mh Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --

package Kernel::System::PostMaster::Filter::RejectDoubledContent;

use strict;
use warnings;

use Kernel::System::Ticket;
use Kernel::System::Email;

use vars qw($VERSION);
$VERSION = qw($Revision: 1.20 $) [1];

sub new {
    my ( $Type, %Param ) = @_;

    # allocate new hash for object
    my $Self = {};
    bless( $Self, $Type );

    $Self->{Debug} = $Param{Debug} || 0;

    # get needed objects
    for (qw(ConfigObject LogObject DBObject MainObject)) {
        $Self->{$_} = $Param{$_} || die "Got no $_!";
    }

    $Self->{TicketObject} = Kernel::System::Ticket->new(%Param);
    $Self->{EmailObject}  = Kernel::System::Email->new(%Param);

    return $Self;
}

sub Run {
    my ( $Self, %Param ) = @_;

    # check needed stuff
    for (qw(JobConfig GetParam)) {
        if ( !$Param{$_} ) {
            $Self->{LogObject}->Log( Priority => 'error', Message => "Need $_!" );
            return;
        }
    }

    # Search for tickets with the same subject, sender and body
    my %MailParams = %{ $Param{GetParam} || {} };
    my @TicketIDs = $Self->{TicketObject}->TicketSearch(
        From => $MailParam{From},
        Subject => $MailParam{Subject},
        Body     => $MailParam{Body},
    );

    # ignore mail if tickets with the same params are found
    if ( @TicketIDs ) {
        $Param{GetParam}->{'X-OTRS-Ignore'} = 'yes';
    }

    return 1;
}

1;
And add this to your Config.pm:

Code: Select all

    $Self->{'PostMaster::PreFilterModule'}->{'0001-DoubledContent'} = {
        Module => 'Kernel::System::PostMaster::Filter::RejectDoubledContent',
    };
(all untested)
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
klausneil
Znuny superhero
Posts: 682
Joined: 29 May 2012, 22:47
Znuny Version: 6.0.24
Real Name: Klaus Salazar
Location: Perú

Re: OTRS against mail repeated

Post by klausneil »

sory but " $Self->{'PostMaster::PreFilterModule'}->{'0001-DoubledContent'} = {
Module => 'Kernel::System::PostMaster::Filter::RejectDoubledContent',
};0"

I can add it anywhere or on a specific line .
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: OTRS against mail repeated

Post by reneeb »

You can add it anywhere within the sub Load
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
klausneil
Znuny superhero
Posts: 682
Joined: 29 May 2012, 22:47
Znuny Version: 6.0.24
Real Name: Klaus Salazar
Location: Perú

Re: OTRS against mail repeated

Post by klausneil »

Excuse my ignorance, but I have that create a file perl with name example RejectDoubledContent.pm in the following path /opt/otrs/Kernel/System/postmaster/Filter/RejectDoubledContent.pm and after this in Config.pm add the line

$Self->{'PostMaster::PreFilterModule'}->{'0001-DoubledContent'} = {
Module => 'Kernel::System::PostMaster::Filter::RejectDoubledContent',
};

The problem is that no exist the path /opt/otrs/Kernel/System/postmaster/Filter
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: OTRS against mail repeated

Post by jojo »

try uppercase for postmaster...
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
klausneil
Znuny superhero
Posts: 682
Joined: 29 May 2012, 22:47
Znuny Version: 6.0.24
Real Name: Klaus Salazar
Location: Perú

Re: OTRS against mail repeated

Post by klausneil »

Hi sorry but I already tried and no exits

root@was:~# ls /opt/otrs/Kernel/
Config/ cpan-lib/ Modules/ System/
Config.pm GenericInterface/ Output/
Config.pm.bak Language/ Scheduler/
Config.pm.dist Language.pm Scheduler.pm

any idea please my otrs i 3.1.10
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: OTRS against mail repeated

Post by jojo »

Kernel/System not Kernel...
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
klausneil
Znuny superhero
Posts: 682
Joined: 29 May 2012, 22:47
Znuny Version: 6.0.24
Real Name: Klaus Salazar
Location: Perú

Re: OTRS against mail repeated

Post by klausneil »

Thanks jojo thanks thanks for your help create achieved thank you so much
rainmaker
Znuny newbie
Posts: 4
Joined: 29 Jan 2013, 13:34
Znuny Version: 3.20.rc1
Real Name: Valeriy

Re: [SOLVED] OTRS against mail repeated

Post by rainmaker »

Hi, want to use this script, but it doesnt work for me.
I still receive identical emails,

I use otrs 3.20.rc1
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: [SOLVED] OTRS against mail repeated

Post by reneeb »

Can you post two sample mails?
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
rainmaker
Znuny newbie
Posts: 4
Joined: 29 Jan 2013, 13:34
Znuny Version: 3.20.rc1
Real Name: Valeriy

Re: [SOLVED] OTRS against mail repeated

Post by rainmaker »

I send 1 message with subject "DP16" and body "DP16", then i send another message with this subject and body. Second message have not been ignored and i've got 2 tickets.


This is my thunderbird log.

Code: Select all

From - Wed Feb 27 14:05:04 2013
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00800000
X-Mozilla-Keys:                                                                                 
Message-ID: <512DDA4A.5080504@hotmail.com>
Date: Wed, 27 Feb 2013 14:04:58 +0400
From: =?UTF-8?B?0JLQsNC70LXRgNC40Lkg0JzQsNC70LjQutC+0LI=?=
 <v.malikov@hotmail.com>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130221 Thunderbird/17.0.3
MIME-Version: 1.0
To: one@maryno.net
Subject: DP16
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

DP16
From - Wed Feb 27 14:05:21 2013
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00800000
X-Mozilla-Keys:                                                                                 
Message-ID: <512DDA5C.2030102@hotmail.com>
Date: Wed, 27 Feb 2013 14:05:16 +0400
From: =?UTF-8?B?0JLQsNC70LXRgNC40Lkg0JzQsNC70LjQutC+0LI=?=
 <v.malikov@hotmail.com>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130221 Thunderbird/17.0.3
MIME-Version: 1.0
To: one@maryno.net
Subject: DP16
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

DP16
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: [SOLVED] OTRS against mail repeated

Post by reneeb »

Can you add

Code: Select all

$Self->{LogObject}->Log( Priority => error => Message => sprintf "%s // %s // %s", $MailParam{From}, $MailParam{Body}, $MailParam{Subject} );
Before the line where TicketSearch is called? Then "import" the two mails again and post the debug output.
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
rainmaker
Znuny newbie
Posts: 4
Joined: 29 Jan 2013, 13:34
Znuny Version: 3.20.rc1
Real Name: Valeriy

Re: [SOLVED] OTRS against mail repeated

Post by rainmaker »

Code: Select all

Thu Feb 28 13:54:49 2013 	notice 	OTRS-CGI-10 	IMAP: Fetched 2 email(s) from one@maryno.net/mail.maryno.net.
Thu Feb 28 13:54:48 2013 	notice 	OTRS-CGI-10 	New Ticket [2013022810000231/DP30] created (TicketID=1246,Queue=test_one,Priority=3 normal,State=new)
Thu Feb 28 13:54:48 2013 	notice 	OTRS-CGI-10 	Take UserCustomerID (v.malikov@hotmail.com) from customer source backend based on (v.malikov@hotmail.com).
Thu Feb 28 13:54:48 2013 	notice 	OTRS-CGI-10 	Take UserLogin (v.malikov) from customer source backend based on (v.malikov@hotmail.com).
Thu Feb 28 13:54:48 2013 	error 	OTRS-CGI-10 	Need UserID or CustomerUserID params for permission check!
Thu Feb 28 13:54:48 2013 	error 	OTRS-CGI-10 	Валерий Маликов <v.malikov@hotmail.com> // DP30
Thu Feb 28 13:54:48 2013 	notice 	OTRS-CGI-10 	New Ticket [2013022810000222/DP30] created (TicketID=1245,Queue=test_one,Priority=3 normal,State=new)
Thu Feb 28 13:54:48 2013 	notice 	OTRS-CGI-10 	Take UserCustomerID (v.malikov@hotmail.com) from customer source backend based on (v.malikov@hotmail.com).
Thu Feb 28 13:54:48 2013 	notice 	OTRS-CGI-10 	Take UserLogin (v.malikov) from customer source backend based on (v.malikov@hotmail.com).
Thu Feb 28 13:54:48 2013 	error 	OTRS-CGI-10 	Need UserID or CustomerUserID params for permission check!
Thu Feb 28 13:54:48 2013 	error 	OTRS-CGI-10 	Валерий Маликов <v.malikov@hotmail.com> // DP30 
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: [SOLVED] OTRS against mail repeated

Post by reneeb »

You have to pass "UserID => 1" to TicketSearch...
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
rainmaker
Znuny newbie
Posts: 4
Joined: 29 Jan 2013, 13:34
Znuny Version: 3.20.rc1
Real Name: Valeriy

Re: [SOLVED] OTRS against mail repeated

Post by rainmaker »

Thank you, it is working now.

Can you help me to add attachment verify to this code?
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: [SOLVED] OTRS against mail repeated

Post by reneeb »

Please be more specific and open a new thread!

If you want to implement more features I recomment to read the developer manual and/or hire someone...
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
Locked