Using PostMaster filters on raw emails

Jens Bothe, 21. 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 most known kind of filters are the “Match Filters” which can be configured through the admin panel.

These filters use Kernel::System::EmailParser to split the content of an incomming email into different parts, like the different headers and the 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 possible 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. This filter 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 not possible with the “normal” filters.

Lets have a look on the raw email:

Subject: Some Test Mail
Message-ID: <dd5236ce@otrs.com>
Date: Wed, 21 Dec 2016 21:08:59 +0100
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
 protocol="application/pgp-signature";
 boundary="cIkbOuFPs5f5mcbVqptdx5bwHgr8Ca53h"

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

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

Hey,
this is a test

((enjoy))
Jens

--QjgNWgJvSE4d1wRcsuMPf9MFTaAMnLIFb--

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

-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org

iEYEARECAAYFAlha4V8ACgkQZ4I/4k742SwdBgCgnNb6NbqLNkNw75eTjeVHhVtY
QLcAoMOW/++VqAOPSwlLRd8delBY5qym
=LpXU
-----END PGP SIGNATURE-----

--cIkbOuFPs5f5mcbVqptdx5bwHgr8Ca53h--

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

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

This site uses cookies. By continuing to use the site, you agree to the use of cookies. More information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close