How to only accept tickets from customers in your database

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

Moderator: crythias

Forum rules
Dont create your support topics here! No new topics with questions allowed!
Post Reply
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

How to only accept tickets from customers in your database

Post by crythias »

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 6.0.x (private/testing/public) on Linux with MySQL database.
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
Znuny newbie
Posts: 1
Joined: 05 May 2010, 22:15
Znuny Version: 2.4.7

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

Post by ccpmz »

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?
diginin
Znuny expert
Posts: 213
Joined: 11 Feb 2008, 12:04
Znuny Version: CVS

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

Post by diginin »

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
Znuny expert
Posts: 250
Joined: 12 Oct 2010, 01:35
Znuny Version: 3.0.9
Company: LRS Health

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

Post by MichaelR »

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
Znuny newbie
Posts: 9
Joined: 01 Mar 2012, 16:49
Znuny Version: OTRS311
Real Name: James Hottinger
Company: Lynx Networks

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

Post by JamesHottinger »

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
Znuny newbie
Posts: 5
Joined: 08 May 2012, 21:50
Znuny Version: 3.1.4
Real Name: Sean Letson
Company: CACI

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

Post by SeanLetson »

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.
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

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

Post by crythias »

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 6.0.x (private/testing/public) on Linux with MySQL database.
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
Znuny wizard
Posts: 392
Joined: 30 Dec 2010, 14:35
Znuny Version: 6.0.x and 5.0.x
Real Name: Giulio Soleni
Company: IKS srl

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

Post by Giulio Soleni »

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 6.0.x on CentOS 7.x with MariaDB 10.2.x database connected to an Active Directory for Agents and Customers.
ITSM and FAQ modules installed.
rmansill
Znuny newbie
Posts: 1
Joined: 22 Feb 2016, 23:49
Znuny Version: 5.0.6

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

Post by rmansill »

Will this workaround work in OTRS 5.0?
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

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

Post by crythias »

In theory, it should ... you might need to change how logging or email alerts work.
https://github.com/OTRS/otrs/blob/rel-5 ... et.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 6.0.x (private/testing/public) on Linux with MySQL database.
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
Znuny newbie
Posts: 2
Joined: 09 Feb 2017, 06:09
Znuny Version: OTRS5
Real Name: Rogha
Company: Atomsapp

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

Post by roghax85 »

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
ProyectPenta
Znuny newbie
Posts: 5
Joined: 19 Jul 2017, 17:56
Znuny Version: OTRS 5
Real Name: Javier
Company: Pentacom

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

Post by ProyectPenta »

Hi! Can i do the same thing for not accept Tickets from customers?? I just want create Ticket with my agents.
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

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

Post by crythias »

For no email created tickets (but allow followups), one thing that you can do is to send tickets to Junk with Junk having an AutoResponse for "Sorry, you can't create tickets this way. Call an agent."

Then add a Generic Agent to purge Junk periodically.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
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
Post Reply