Customize Postmaster Filter

Moderator: crythias

Post Reply
ndhvu275
Znuny advanced
Posts: 139
Joined: 06 Nov 2012, 09:02
Znuny Version: 3.x, 4.x and 5.x
Real Name: Vu Nguyen
Company: INFOdation
Location: Netherlands
Contact:

Customize Postmaster Filter

Post by ndhvu275 »

Dears,

I had some requirements about filter the incoming emails via the email template. I'd like to give an example like this:
The body of incoming email
Name: me
Address: blah, blah
Product: ABC
...

Service list in OTRS using for Products list
ABC
DEF
XYZ

The requirement is get the value of Product in the body of incoming email (is ABC in this case), then compare with services list. If it is not existed in list, then reject email, otherwise create a ticket and service is assigned ABC

For this requirement, my boss told let do by configuration if possible, but now I'm still not know how to config. It should be changed some code I think. Please help me, give me some suggestions.

Thanks a lot,

Vu Nguyen
OTRS 3.x, 4.x on CentOS/Windows
MySQL database
External customer backend with MySQL, MSSQL
Customization
juanman80
Znuny newbie
Posts: 44
Joined: 11 Nov 2011, 10:30
Znuny Version: 5.0.15

Re: Customize Postmaster Filter

Post by juanman80 »

Hi,
I would do it the following:
  • - First, I would have two queues: one for the tickets that correctly pass the test [e.g. _Raw_] and one for those that do not pass the test [e.g. _Junk_]
    - In mail account, I would set Dispatching by selected queue and queue: Junk
    - In Postmaster Filter, I would create the following:
    • - Stop after match: Yes
      - Filter Condition->Header 1: Body
      - Filter Condition->Value 1: Product: (\w+)
      - Set Email Headers->Header 1: X-OTRS-Service:
      - Set Email Headers->Value 1: [***]
      - Set Email Headers->Header 2:X-OTRS-Queue
      - Set Email Headers->Value 2:Raw
This way,
  • - all your tickets in Junk queue are those with no product,
    - all your tickets in Raw queue have a product.
In this example, OTRS would still accept tickets with products not in your service list, but I think this is a valid starting point.
OTRS 5.0.15 on CentOSLinux with MariaDB database connected to an Active Directory for Agents and Customers.
ndhvu275
Znuny advanced
Posts: 139
Joined: 06 Nov 2012, 09:02
Znuny Version: 3.x, 4.x and 5.x
Real Name: Vu Nguyen
Company: INFOdation
Location: Netherlands
Contact:

Re: Customize Postmaster Filter

Post by ndhvu275 »

Hi juanman80,

Thank your solution. It's very nice, but my problem was here:
Filter Condition->Value 1: Product: (\w+)
The requirement, the value of Product (\w+) must be check existed in Service list or not? if not the ticket of email must be in the Junk queue.

P/s: you set the Value 1: [***], it's auto lookup from (\w*), am I right? So if I want to filter more field in Body (for example to get value of Adress), how can I config

Thanks & best regards,

Vu Nguyen
OTRS 3.x, 4.x on CentOS/Windows
MySQL database
External customer backend with MySQL, MSSQL
Customization
juanman80
Znuny newbie
Posts: 44
Joined: 11 Nov 2011, 10:30
Znuny Version: 5.0.15

Re: Customize Postmaster Filter

Post by juanman80 »

Hi Vu,
I'm afraid that that's all my know-how without programming a custom postmail filter. If you want to try, you can see some working filter in

Code: Select all

$OTRS_HOME/Kernel/System/PostMaster/Filter/
Yes, [***] will store the result of the last matched () in the regexp... if you put several parentheses, I'm afraid it will only store the last pair

Kind regards,
Juan Clavero
OTRS 5.0.15 on CentOSLinux with MariaDB database connected to an Active Directory for Agents and Customers.
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Customize Postmaster Filter

Post by crythias »

If you have an email template, you should include any x-otrs headers
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
ndhvu275
Znuny advanced
Posts: 139
Joined: 06 Nov 2012, 09:02
Znuny Version: 3.x, 4.x and 5.x
Real Name: Vu Nguyen
Company: INFOdation
Location: Netherlands
Contact:

Re: Customize Postmaster Filter

Post by ndhvu275 »

Thanks all,

For this case, I customized NewTicket.pm file in System/Postmaster/, customer is so happy with that.

Vu Nguyen
OTRS 3.x, 4.x on CentOS/Windows
MySQL database
External customer backend with MySQL, MSSQL
Customization
Post Reply