How to only accept tickets from customers in your database

Dont create your support topics here! No new topics with questions allowed!

Moderator: crythias

User avatar
crythias
Moderator
Posts: 9920
Joined: 04 May 2010, 18:38
OTRS Version?: 4.0.x
Location: SouthWest Florida, USA
Contact:

How to only accept tickets from customers in your database

Postby crythias » 04 Nov 2010, 14:32

Kernel/System/PostMaster/NewTicket.pm around line 135 original code follows

Code: Select all

    # if there is no customer user found!
    if ( !$GetParam{'X-OTRS-CustomerUser'} ) {
        $GetParam{'X-OTRS-CustomerUser'} = $GetParam{SenderEmailAddress};
    }


Sample code to change:

Code: Select all

    # if there is no customer user found!
    if ( !$GetParam{'X-OTRS-CustomerUser'} ) {
            $Self->{LogObject}->Log( Priority => 'info', Message => "$_ not in database" );
            return;
    }


  • Back up the file before editing
  • This change can not be bypassed (you can never create a new ticket via email without being in the customer database) -- I think(?)
  • If you want, you can change "info" to "notice" or "error" depending on how you want to log this message
  • This change WILL get overwritten by updates.

Note: if you've seen this elsewhere, I removed the "no CustomerID" entry. This sub of NewTicket.pm is the check for all ways to get a CustomerUser. The last thing it tries is to see if there is an X-OTRS-CustomerUser entry. If that entry does NOT exist, the default code attempts to make a new CustomerUser from the SenderEmailAddress. The above change simply rejects the ticket and adds a log entry.
OTRS 4.0.x (private/testing/public) on Linux with MySQL database. Also on github.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask

ccpmz
OTRS newbie
Posts: 1
Joined: 05 May 2010, 22:15
OTRS Version?: 2.4.7

Re: How to only accept tickets from customers in your databa

Postby ccpmz » 04 Jan 2011, 21:27

My OTRS 2.4.7 use Active Directory. OTRS allows the agents to create a ticket phone even when he types an invalid customer (from).
How can i do for customer check on tickets phone creation?

User avatar
diginin
Moderator
Posts: 213
Joined: 11 Feb 2008, 12:04
OTRS Version?: CVS

Re: How to only accept tickets from customers in your databa

Postby diginin » 08 Apr 2011, 13:40

Should this be an option, rather then a hack? Try OTRS Team Ideasplease, if you feel so.
Shawn Beasley
Contact me per XING
Contact me per LinkedIN

OTRS CVS on Ubuntu Stable.

Image
signature by diginin74, on Flickr

Computers are like air conditioners, when you open windows they are useless.



P.S. (für Leser meiner Deutschtexte) Rechtschreibfehler bitte mit s/.*/$KORREKTUR/ ersetzen.

MichaelR
OTRS superhero
Posts: 250
Joined: 12 Oct 2010, 01:35
OTRS Version?: 3.0.9
Company: LRS Health

Re: How to only accept tickets from customers in your databa

Postby MichaelR » 14 Apr 2011, 03:34

Posting this again!

I have written up a little addon to crythias' code that also sends a notification email to whomever you want. It also includes in an attachment the body and subject of the blocked incoming email.

1st Section: You need to add the email object definition in the 'sub new'

FILE: OTRS/Kernel/System/PostMaster/NewTicket.pm

Code: Select all

# get all objects
    for (qw(DBObject ConfigObject TicketObject LogObject ParserObject TimeObject QueueObject)) {
        $Self->{$_} = $Param{$_} || die 'Got no $_';
    }

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

    return $Self;
 


2nd Section: You add the Email Object and fill out the details

Code: Select all

# if there is no customer user found!
    if ( !$GetParam{'X-OTRS-CustomerUser'} ) {
        $GetParam{'X-OTRS-CustomerUser'} = $GetParam{SenderEmailAddress};
        
        
# First we write the issue to log, then we send out an email! - MichaelR
        $Self->{LogObject}->Log( Priority => 'info', Message => "$_ not in database, rejecting and sending email" );
        
        
# Send Agent an email to notify of blocked ticket - MichaelR
        $Self->{EmailObject}->Send(
            To         => 'whoever-you-want@yourdomain.com',
            From       => 'postmaster-address@yourdomain.com',
            Subject    => "OTRS has blocked an unknown incoming ticket from: $GetParam{SenderEmailAddress}",
            Body       => "Hello <whoever>,\r\nOTRS recieved an email from $GetParam{SenderEmailAddress} attempting to log a task.\r\nOTRS doesn't know who this is and has NOT created a ticket.\r\nAttached is the body of their email.\r\nWe need to sort this out so it doesn't happen next time.",
            Charset    => $Self->{ConfigObject}->Get('DefaultCharset'),
            MimeType   => 'text/plain',
            Loop       => 1,
            Attachment => [
                {
                    Filename    => 'customer-email.txt',
                    Content     => "Subject: $Param{GetParam}->{Subject}\r\nBody: $Param{GetParam}->{Body}",
                    ContentType => 'application/octet-stream',
                }
            ],
        );
        return;
    }
 


That should be about it....
(I have submitted this to the OTRS Idea's thingo)

Cheers,
Michael

edit by crythias: removed color tag in code
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

JamesHottinger
OTRS newbie
Posts: 9
Joined: 01 Mar 2012, 16:49
OTRS Version?: OTRS311
Real Name: James Hottinger
Company: Lynx Networks

Re: How to only accept tickets from customers in your databa

Postby JamesHottinger » 04 Mar 2012, 20:57

Say you would want to return the blocked message to the sender, would you use $GetParam{SenderEmailAddress} for the 'To' field?

thanks
James Hottinger
Running OTRS Helpdesk 3.1.1 on Windows 7.

SeanLetson
OTRS newbie
Posts: 5
Joined: 08 May 2012, 21:50
OTRS Version?: 3.1.4
Real Name: Sean Letson
Company: CACI

Re: How to only accept tickets from customers in your databa

Postby SeanLetson » 15 Jun 2012, 16:34

I'm running OTRS 3.1.4 and this workaround hasn't been written into it yet that I can find. It should be, I'm tired of having email tickets created for the sale of cheap viagra even with the spamassassin running.

User avatar
crythias
Moderator
Posts: 9920
Joined: 04 May 2010, 18:38
OTRS Version?: 4.0.x
Location: SouthWest Florida, USA
Contact:

Re: How to only accept tickets from customers in your databa

Postby crythias » 18 Jun 2012, 06:55

JamesHottinger wrote:Say you would want to return the blocked message to the sender, would you use $GetParam{SenderEmailAddress} for the 'To' field?

Probably ... you may also consider not doing anything automatic. Well, there's that possibility that you're replying to the Viagra spammer fake email, which means you get an NDR (unless your send-from is some sort of "no-reply@') from your spammer, which *might* create a ticket (the NDR is a new ticket), except it won't, because the abuse@/postmaster@ should be filtered or the infinite loop controls should be working, but still...
OTRS 4.0.x (private/testing/public) on Linux with MySQL database. Also on github.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask

Giulio Soleni
OTRS superhero
Posts: 378
Joined: 30 Dec 2010, 14:35
OTRS Version?: 5.0.x and 4.0.x
Real Name: Giulio Soleni
Company: IKS srl

Re: How to only accept tickets from customers in your databa

Postby Giulio Soleni » 04 Aug 2014, 15:09

Hi,
crythias, would you please take a look to viewtopic.php?f=62&t=25991 ?
Trying to apply your suggestion to a 3.3.x system, it seems to produce some annoying side effects on further IMAP (and presumably also POP3) email processing.
Maybe this effect was already expected when you applied this customization to the previous version of OTRS, but I would like to know if it can be somehow avoided.

Thank you
OTRS 5.0.x on CentOS 6.9 with MySQL 5.6 database connected to an Active Directory for Agents and Customers.
ITSM and FAQ modules installed.

rmansill
OTRS newbie
Posts: 1
Joined: 22 Feb 2016, 23:49
OTRS Version?: 5.0.6

Re: How to only accept tickets from customers in your database

Postby rmansill » 22 Feb 2016, 23:51

Will this workaround work in OTRS 5.0?

User avatar
crythias
Moderator
Posts: 9920
Joined: 04 May 2010, 18:38
OTRS Version?: 4.0.x
Location: SouthWest Florida, USA
Contact:

Re: How to only accept tickets from customers in your database

Postby crythias » 06 Jul 2016, 18:43

In theory, it should ... you might need to change how logging or email alerts work.
https://github.com/OTRS/otrs/blob/rel-5_0/Kernel/System/PostMaster/NewTicket.pm#L212

Code: Select all

            $Kernel::OM->Get('Kernel::System::Log')->Log(
                Priority => 'Info',
                Message  => "$_ not in database"
            );
            return;


MichaelR's email send notification will need to be update to the new object model.
OTRS 4.0.x (private/testing/public) on Linux with MySQL database. Also on github.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask

roghax85
OTRS newbie
Posts: 2
Joined: 09 Feb 2017, 06:09
OTRS Version?: OTRS5
Real Name: Rogha
Company: Atomsapp

Re: How to only accept tickets from customers in your database

Postby roghax85 » 09 Feb 2017, 06:56

Hello.

I am new on otrs, I need help to apples this on my version 5 instale.

Please help me to know what add to the code....

Regards


Return to “Howtos”

Who is online

Users browsing this forum: No registered users and 1 guest