EnhancedPostmasterFilter - use named captures in Postmaster filter
Currently you have to develop your own PostMaster filter module when you want to catch several values from the mail and use them to set e.g. dynamic fields. The shipped module allows you only to use
[***] to use the captured value in the "set" actions. But what is the captured value?
OTRS checks the fields defined in the "match" section in alphabetical order. So
[***] is the value captured with the last capturing groups (
()) of the last (in alphabetical order) field.
But what if you want to capture more values and use them? Then go with this module!
Now you can use names for the capturing groups and use the names in the "set" actions.
The following mail is a maintenance notification and you want to catch the two server IPs in the mail body and the customer ID in the subject. And finally you want to use those values to set the dynamic field Test to the customer ID and the dynamic field Servers to "xxxxxxx and yyyyyy".
Return-Path: <email@example.com> X-Original-To: firstname.lastname@example.org Delivered-To: email@example.com Received: from xxxx (xxxxxxxx) by mail.xxxxxx (Postfix) with ESMTPS id xxxxx for <firstname.lastname@example.org>; Thu, 18 Dec 2014 13:13:22 +0100 (CET) To: email@example.com Subject: Maintenance CustomerID 123456 From: firstname.lastname@example.org MIME-Version: 1.0 Reply-To: email@example.com Message-ID: <c2ac0b64d099e9cdb90cd6bcxxxx@server02> Date: Thu, 18 Dec 2014 13:13:22 +0100 There will be maintenance on Sunday for these servers: 127.0.0.1 184.108.40.206
Now you can define these matches:
Field: Body Value: \n\n(?<s1>\d+\.\d+\.\d+\.\d+)\n(?<s2>\d+\.\d+\.\d+\.\d+) Field: Subject Value: CustomerID (?<cid>\d+)
And these set actions:
Field: X-OTRS-DynamicField-Test Value: [**\cid**] Field: X-OTRS-DynamicField-Servers Value: [**\s1**] and [**\s2**]
The development of this addon was sponsored by Caritasverband Westerwald-Rhein-Lahn e.V.
The code repository and a bugtracker is available at https://github.com/reneeb/otrs-EnhancedPostmasterFilter. Please report any bugs and feature requests on GitHub or via mail.
This package was written by Renee Baecker <firstname.lastname@example.org>.
The package is licensed under AGPL 3.0. If you did not receive this file, see http://www.gnu.org/licenses/agpl.txt.