Filtering/dispatching by OTRS/PostMaster modules (for more complex dispatching)

If you use the PostMaster.pl or PostMasterPOP3.pl method, the you can modify X-OTRS header with the OTRS/PostMaster filter modules.

For example you can set the priority or the queue of an ticket with the PostMaster filter modules.

There are some default filter modules:

Note: The job name (e. g. $Self->{'PostMaster::PreFilterModule'}->{'JobName'}) needs to be uniq!

Kernel::System::PostMaster::Filter::Match is a default module to match on some email header (e. g. From, To, Subject, ...) and then to set new email header (e. g. X-OTRS-Ignore: yes or X-OTRS-Queue: spam).
Kernel/Config.pm
[...]
    # Job Name: 1-Match 
    # (block/ignore all spam email with From: noreply@)
    $Self->{'PostMaster::PreFilterModule'}->{'1-Match'} = {
        Module => 'Kernel::System::PostMaster::Filter::Match',
        Match => {
            From => 'noreply@',
        },
        Set => {
            'X-OTRS-Ignore' => 'yes',
        },
    };
    # Job Name: 2-Match
    # (sort emails with From: sales@example.com and Subject: **ORDER**
    # into queue 'Order')
    $Self->{'PostMaster::PreFilterModule'}->{'2-Match'} = {
        Module => 'Kernel::System::PostMaster::Filter::Match',
        Match => {
            To => 'sales@example.com',
            Subject => '**ORDER**',
        },
        Set => {
            'X-OTRS-Queue' => 'Order',
        },
    };
[...]

Kernel::System::PostMaster::Filter::CMD is a default module to pipe the email into an external cmd and it the result on STDOUT is true, then set new email header (e. g. X-OTRS-Ignore: yes or X-OTRS-Queue: spam).
Kernel/Config.pm
[...]
    # Job Name: 5-SpamAssassin 
    # (SpamAssassin example setup, ignore spam emails)
    $Self->{'PostMaster::PreFilterModule'}->{'5-SpamAssassin'} = {
        Module => 'Kernel::System::PostMaster::Filter::CMD',
        CMD => '/usr/bin/spamassassin | grep -i "X-Spam-Status: yes"',
        Set => {
            'X-OTRS-Ignore' => 'yes',
        },
    };
[...]

Of cource, it's also possible to develop own PostMaster filter modules.

There is also a list of all usable X-OTRS header in doc/X-OTRS-Headers.txt.