(SOLVED) Receive into OTRS from only registered users

Moderator: crythias

Locked
morecw
Znuny expert
Posts: 215
Joined: 18 Jun 2012, 09:24
Znuny Version: 3.1.6
Real Name: Craig Wellman
Company: STÜBER SYSTEMS

(SOLVED) Receive into OTRS from only registered users

Post by morecw »

Hi all,

we would like only registered customers to be able to email through OTRS. Incoming messages should not create a ticket, instead reply to the sender requesting that they first register a customer account on the Customer.pl

Is this possible to configure with the PostMaster Filter or something else? I can't figure out how.

Thanks in advance
Last edited by morecw on 07 Sep 2012, 11:00, edited 1 time in total.
OTRS 3.1.6, Windows 2008 with MySQL database
Firefox 14, Chrome 22
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Receive customer emails into OTRS from only registered u

Post by crythias »

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
morecw
Znuny expert
Posts: 215
Joined: 18 Jun 2012, 09:24
Znuny Version: 3.1.6
Real Name: Craig Wellman
Company: STÜBER SYSTEMS

Re: Receive customer emails into OTRS from only registered u

Post by morecw »

Ok good that it's possible. But it still has to be done via a hack?
OTRS 3.1.6, Windows 2008 with MySQL database
Firefox 14, Chrome 22
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Receive customer emails into OTRS from only registered u

Post by crythias »

morecw wrote:Ok good that it's possible. But it still has to be done via a hack?
Yes, unless you want to reject at your mailserver, or build your own postmaster filter.
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
morecw
Znuny expert
Posts: 215
Joined: 18 Jun 2012, 09:24
Znuny Version: 3.1.6
Real Name: Craig Wellman
Company: STÜBER SYSTEMS

Re: Receive customer emails into OTRS from only registered u

Post by morecw »

In the end I did what was suggested in the post but I have a problem now, I can't FetchMail anymore as I receive an error. Could you please suggest from my code examples what could be wrong?

Errors

"Error Message: Attempt to reload Kernel/System/PostMaster.pm aborted. Compilation failed in req[..]"

Backend ERROR: OTRS-CGI-10 Perl: 5.12.3 OS: MSWin32 Time: Fri Sep 7 01:41:43 2012 Message: Attempt to reload Kernel/System/PostMaster.pm aborted. Compilation failed in require at C:/PROGRA~1/OTRS/OTRS//Kernel/System/MailAccount/IMAPS.pm line 17. BEGIN failed--compilation aborted at C:/PROGRA~1/OTRS/OTRS//Kernel/System/MailAccount/IMAPS.pm line 17. Traceback (2064): Module: Kernel::System::MailAccount::MailAccountFetch (v1.17) Line: 418 Module: Kernel::Modules::AdminMailAccount::Run (v1.28) Line: 69 Module: Kernel::System::Web::InterfaceAgent::Run (v1.64) Line: 868 Module: ModPerl::ROOT::ModPerl::Registry::C_3a_Program_20Files_OTRS_OTRS_bin_cgi_2dbin_index_2epl::handler (unknown version) Line: 49 Module: (eval) (v1.90) Line: 204 Module: ModPerl::RegistryCooker::run (v1.90) Line: 204 Module: ModPerl::RegistryCooker::default_handler (v1.90) Line: 170 Module: ModPerl::Registry::handler (v1.99) Line: 31

Kernel\System\PostMaster\NewTicket.pm

Code: Select all

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

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

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

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

    $Self->{CustomerUserObject} = Kernel::System::CustomerUser->new(%Param);
    [color=#FF0000]$Self->{EmailObject}  = Kernel::System::Email->new(%Param);[/color]

    return $Self;
}  

Code: Select all

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

      $Self->{LogObject}->Log( Priority => 'info', Message => "$_ not in database, rejecting and sending email" );
      
      # Send Agent an email to notify of blocked ticket
      $Self->{EmailObject}->Send(
         To         => '$GetParam{SenderEmailAddress}',
         From       => 'no-reply@oursite.de',
         Subject    => "OTRS has blocked an unknown incoming ticket from: $GetParam{SenderEmailAddress}",
         Body       => "Sehr geehrte Damen und Herren,\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;
     }
##################### End of changes  
Last edited by morecw on 09 Nov 2012, 17:44, edited 4 times in total.
OTRS 3.1.6, Windows 2008 with MySQL database
Firefox 14, Chrome 22
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Receive customer emails into OTRS from only registered u

Post by crythias »

The first part of the code you posted wasn't what you needed to change.
The problem is that the code MichaelR posted had BBcode color added.

He said : "You need to add the *email object definition* in the 'sub new".
basically, after
$Self->{CustomerUserObject} = Kernel::System::CustomerUser->new(%Param);
add this
$Self->{EmailObject} = Kernel::System::Email->new(%Param);
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
morecw
Znuny expert
Posts: 215
Joined: 18 Jun 2012, 09:24
Znuny Version: 3.1.6
Real Name: Craig Wellman
Company: STÜBER SYSTEMS

Re: Receive customer emails into OTRS from only registered u

Post by morecw »

crythias wrote:The first part of the code you posted wasn't what you needed to change.
The problem is that the code MichaelR posted had BBcode color added.

He said : "You need to add the *email object definition* in the 'sub new".
basically, after
$Self->{CustomerUserObject} = Kernel::System::CustomerUser->new(%Param);
add this
$Self->{EmailObject} = Kernel::System::Email->new(%Param);
Sorry I was really tired last night and posted the wrong code by mistake! I meant actually the post the sub new part. Anyway I've replaced that part now with what you have suggested and kept the second half. It does error now which is good and it no longer accepts requests from unregistered customers. The only problem remaining is it is not sending an email response to the sender.

So I now have:

Code: Select all

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

Code: Select all

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

      $Self->{LogObject}->Log( Priority => 'info', Message => "$_ not in database, rejecting and sending email" );
      
      # Send Agent an email to notify of blocked ticket
      $Self->{EmailObject}->Send(
         To         => '$GetParam{SenderEmailAddress}',
         From       => 'no-reply@oursite.de',
         Subject    => "OTRS has blocked an unknown incoming ticket from: $GetParam{SenderEmailAddress}",
         Body       => "Sehr geehrte Damen und Herren,\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;
     }
Last edited by morecw on 09 Nov 2012, 17:44, edited 1 time in total.
OTRS 3.1.6, Windows 2008 with MySQL database
Firefox 14, Chrome 22
morecw
Znuny expert
Posts: 215
Joined: 18 Jun 2012, 09:24
Znuny Version: 3.1.6
Real Name: Craig Wellman
Company: STÜBER SYSTEMS

Re: Receive customer emails into OTRS from only registered u

Post by morecw »

Ok found the problem. Have removed the quotes around $GetParam{SenderEmailAddress} in To.
OTRS 3.1.6, Windows 2008 with MySQL database
Firefox 14, Chrome 22
Locked