OTRS Mail Filter

Moderator: crythias

Locked
TheJoker1967
Znuny newbie
Posts: 8
Joined: 20 Dec 2011, 17:07
Znuny Version: 3.0.11

OTRS Mail Filter

Post by TheJoker1967 »

Hello,

I have OTRS 3.0.11. I want to send an E-Mail from a special adress to otrs with the customer number. The mail header looks like

Code: Select all

To: <xyz@xyz>
Subject: xyz
From: <xyz@xyz>
X-OTRS-CustomerNo: 1
Content-Type: text/plain; charset="UTF-8"
MIME-Version: 1.0
In the mailfilter i'm looking for subject an from adress and set X-OTRS-Queue.

But the customer is set to the from adress?

Greetings

TJ
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: OTRS Mail Filter

Post by jojo »

is the mail account set to trusted? otherwise the X-OTRS Headers will be deleted
"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
TheJoker1967
Znuny newbie
Posts: 8
Joined: 20 Dec 2011, 17:07
Znuny Version: 3.0.11

Re: OTRS Mail Filter

Post by TheJoker1967 »

Okay thanks. But now I have two more questions.

1. The number is correct now. But the mailadress is wrong. Is it possible to set the default mailadress from customer database for the customer number? Now there ist number 1 and xyz@xyz but i want to have number 1 and customermail1@customermail.

2. I have only one mailaccount at the moment. So bad guys could manipulate mails? Is it better to use a second mailaccound for trusted mails?
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: OTRS Mail Filter

Post by jojo »

For the User you need to set X-OTRS-CustomerUser

yes, you should use a second account (which should also be secured on the MTA Level)
"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
TheJoker1967
Znuny newbie
Posts: 8
Joined: 20 Dec 2011, 17:07
Znuny Version: 3.0.11

Re: OTRS Mail Filter

Post by TheJoker1967 »

Ok.

I'm sending the mail from an embedded system. I have no chance to store customer number and user anywhere. Is it possible to write a little perl script for the filter which lookup the user? Where should i place this script?

Greetings

TJ
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: OTRS Mail Filter

Post by jojo »

you can set alternate addresses in the customer database as OTRS ( extend CustomerUserPostMasterSearchFields => ['email'],)
"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
TheJoker1967
Znuny newbie
Posts: 8
Joined: 20 Dec 2011, 17:07
Znuny Version: 3.0.11

Re: OTRS Mail Filter

Post by TheJoker1967 »

I use the default Customer Backend is it enough to set this in the Default.pm

Code: Select all

  $Self->{CustomerUser} = {
    CustomerUserPostMasterSearchFields => ['email']
  };
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: OTRS Mail Filter

Post by jojo »

never change Defaults.pm!
"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
TheJoker1967
Znuny newbie
Posts: 8
Joined: 20 Dec 2011, 17:07
Znuny Version: 3.0.11

Re: OTRS Mail Filter

Post by TheJoker1967 »

So where I have to put CustomerUserPostMasterSearchFields => ['email']? I haven't change anything in the customer backend.
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: OTRS Mail Filter

Post by jojo »

you have to copy the whole CustomerUser part to Config.pm, you need to alter the database table to include a second or third email field. Then you need to change the value in the CustomerUser declaration to include all columns storing email addresses of the customer
"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
TheJoker1967
Znuny newbie
Posts: 8
Joined: 20 Dec 2011, 17:07
Znuny Version: 3.0.11

Re: OTRS Mail Filter

Post by TheJoker1967 »

Okay. This is the config from the docs.

Code: Select all

# CustomerUser (customer database backend and settings)
$Self->{CustomerUser} = {
    Name => 'Database Datasource',
    Module => 'Kernel::System::CustomerUser::DB',
    Params => {
        # if you want to use an external database, add the required settings
#            DSN => 'DBI:odbc:yourdsn',
#            DSN => 'DBI:mysql:database=customerdb;host=customerdbhost',
#            User => '',
#            Password => '',
            Table => 'customer_user',
            # if your frontend is unicode and the charset of your
            # customer database server is iso-8859-1, use these options.
#           SourceCharset => 'iso-8859-1',
#           DestCharset => 'utf-8',

            # CaseSensitive will control if the SQL statements need LOWER()
            #   function calls to work case insensitively. Setting this to
            #   1 will improve performance dramatically on large databases.
            CaseSensitive => 0,
        },
# customer unique id
CustomerKey => 'login',

# customer #
CustomerID => 'customer_id',
CustomerValid => 'valid_id',
    CustomerUserListFields => ['first_name', 'last_name', 'email'],
    CustomerUserSearchFields => ['login', 'last_name', 'customer_id'],
    CustomerUserSearchPrefix => '',
    CustomerUserSearchSuffix => '*',
    CustomerUserSearchListLimit => 250,
    CustomerUserPostMasterSearchFields => ['email'],
    CustomerUserNameFields => ['title','first_name','last_name'],
    CustomerUserEmailUniqCheck => 1,
#    # show not own tickets in customer panel, CompanyTickets
#    CustomerUserExcludePrimaryCustomerID => 0,
#    # generate auto logins
#    AutoLoginCreation => 0,
#    AutoLoginCreationPrefix => 'auto',
#    # admin can change customer preferences
#    AdminSetPreferences => 1,
#    # cache time to live in sec. - cache any database queries
#    CacheTTL => 0,
#    # just a read only source
#    ReadOnly => 1,
    Map => [
        # note: Login, Email and CustomerID needed!
        # var, frontend, storage, shown (1=always,2=lite), required, storage-type, http-link, readonly, http-link-target
        [ 'UserTitle',      'Title',      'title',      1, 0, 'var', '', 0 ],
        [ 'UserFirstname',  'Firstname',  'first_name', 1, 1, 'var', '', 0 ],
        [ 'UserLastname',   'Lastname',   'last_name',  1, 1, 'var', '', 0 ],
        [ 'UserLogin',      'Username',   'login',      1, 1, 'var', '', 0 ],
        [ 'UserPassword',   'Password',   'pw',         0, 0, 'var', '', 0 ],
        [ 'UserEmail',      'Email',      'email',      1, 1, 'var', '', 0 ],

#        [ 'UserEmail',      'Email', 'email',           1, 1, 'var', '$Env{"CGIHandle"}?Action=AgentTicketCompose&ResponseID=1&TicketID=$Data{"TicketID"}&ArticleID=$Data{"ArticleID"}', 0 ],
        [ 'UserCustomerID', 'CustomerID', 'customer_id', 0, 1, 'var', '', 0 ],

#        [ 'UserCustomerIDs', 'CustomerIDs', 'customer_ids', 1, 0, 'var', '', 0 ],
        [ 'UserPhone',        'Phone',       'phone',        1, 0, 'var', '', 0 ],
        [ 'UserFax',          'Fax',         'fax',          1, 0, 'var', '', 0 ],
        [ 'UserMobile',       'Mobile',      'mobile',       1, 0, 'var', '', 0 ],
        [ 'UserStreet',       'Street',      'street',       1, 0, 'var', '', 0 ],
        [ 'UserZip',          'Zip',         'zip',          1, 0, 'var', '', 0 ],
        [ 'UserCity',         'City',        'city',         1, 0, 'var', '', 0 ],
        [ 'UserCountry',      'Country',     'country',      1, 0, 'var', '', 0 ],
        [ 'UserComment',      'Comment',     'comments',     1, 0, 'var', '', 0 ],
        [ 'ValidID',          'Valid',       'valid_id',     0, 1, 'int', '', 0 ],
    ],
    # default selections
    Selections => {
        UserTitle => {
            'Mr.' => 'Mr.',
            'Mrs.' => 'Mrs.',
        },
    },
};
There is allready CustomerUserPostMasterSearchFields => ['email']. Is the default config enough? At the moment with the default config every customer has an e-mail adress defined. Why I need a second colum?
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: OTRS Mail Filter

Post by jojo »

as you wrote
But the mailadress is wrong. Is it possible to set the default mailadress from customer database for the customer number? Now there ist number 1 and xyz@xyz but i want to have number 1 and customermail1@customermail.
so it seems that xyz@xyz is not in customer DB so you need to add it...
"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
TheJoker1967
Znuny newbie
Posts: 8
Joined: 20 Dec 2011, 17:07
Znuny Version: 3.0.11

Re: OTRS Mail Filter

Post by TheJoker1967 »

I havent insert this config from above i only checked the docs. Should i copy this code in my Config.pm?


Here a dump from customerid 1. There is the e-mail adress and the customerno.

Code: Select all

INSERT INTO `customer_user` (`id`, `login`, `email`, `customer_id`, `pw`, `title`, `first_name`, `last_name`, `phone`, `fax`, `mobile`, `street`, `zip`, `city`, `country`, `comments`, `valid_id`, `create_time`, `create_by`, `change_time`, `change_by`) VALUES
(3, 'test.test', 'xyz@xyz', '1', '$1$xyz', '', 'test', 'test', '', '', '', '', '', '', '', '', 1, 'xyz', 2, 'xyz', 2),
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: OTRS Mail Filter

Post by jojo »

I'm really not understanding your problem. If the email address is stored OTRS will assign the Customer ID and CustomerUser without any additional X-Headers. If the email Address is not stored, you need to add an additional column in the customer database to store the additional email Adrress for this customer.
"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
TheJoker1967
Znuny newbie
Posts: 8
Joined: 20 Dec 2011, 17:07
Znuny Version: 3.0.11

Re: OTRS Mail Filter

Post by TheJoker1967 »

Okay sorry. My english is not so good but i try to explain again.

I want to recive calls on an embedded system. There the customer can type his customer no with his phone. The system should send an e-mail from test@xyz to otrs with the X-Header customer number. This is working know after your help but in the ticket there is the right customer number but there is also the test@xyz adress. So the autoresponder would send it to test@xyz. I want that the filter adds the right customer e-mail adress (from the database) at this point and not the test@xyz. From the embedded system i have no chance to connect to mysql or an api, only mail is working.
Locked