Using PostMaster filters on raw emails

Jens Bothe21. Dec 2016 | AdministrationConsultingUse cases

OTRS has a deep background on handling emails. One of the most powerful tools integrated is the ability to analyze incoming emails and even fetch data to different fields of a ticket. The best known filters are the “Match Filters” which can be configured through the admin panel.

These filters use Kernel::System::EmailParser to split the content of incoming emails into different parts, like the headers and body. Due to this splitting, it is not possible to analyze parts of an email which are not stored in the headers or the body.

Solving the issue

Deeply hidden in the Sysconfig, is the possibility to create postmaster filters which use the raw or plaintext content. This filter can be found in the PostMaster::PreFilterModule###4-CMD section of the Ticket -> Core::PostMaster group and matches if the command will create an output on STDOUT.

Let’s say I would like to set a Dynamic Field if the mail was signed by PGP/MIME. As the PGP signature is an additional MIME part within the mail, this is not possible with the regular filters.

Lets have a look on the raw email:

Subject: Some Test Mail
Message-ID: <>
Date: Wed, 21 Dec 2016 21:08:59 +0100
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
Content-Type: multipart/mixed; boundary="QjgNWgJvSE4d1wRcsuMPf9MFTaAMnLIFb";
From: "Jens O. Bothe" <>
To: 'Jens Bothe' <>
Message-ID: <>
Subject: Some Test Mail

Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

this is a test



Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

Comment: GPGTools -



I want to filter on the part:

Content-Type: application/pgp-signature; name="signature.asc"

So I have to add as CMD: grep “Content-Type: application/pgp-signature”

The full part in the Sysconfig

For my latest customer I created some additional filters. The XML file can be found here: PostMasterFilter.xml

Theo at 09.07.2020, 11:37

Hi, I'm new to OTRS (community edition), and while reading your post I was wondering : When does this filtering occurs ? Is it happening between the moment you received a mail and before the ticket is created ? And is it possible to apply filters with something external to OTRS, like an ERP or a LDAP server ? (Any hints to do so will be very welcomed)

Jens Bothe at 18.04.2019, 10:02

You would need to develop your own filters

Prashant Jain at 18.04.2019, 07:02

can we remove some text/html content of the mail body based on filter criteria - Post Master Filter? Example if the incoming html email containssome logo and copyright then remove that logo and copyright string.

Your email address will not be published. Required fields are marked *