OTRS CVS - Manual
Prev | Chapter 7. Receiving emails | Next

# Filtering/dispatching by Procmail (for more complex dispatching)

If you use the PostMaster.pl method, the you can add X-OTRS header to the email and PostMaster.pl will use this header by piping the email into PostMaster.pl.

The X-OTRS-Queue Mail-Header

The X-OTRS-Queue Mail-Header is parsed by OTRS and OTRS will pipe these e-mails direct in this queue. Procmail and fromail can be used to create a powerfull dispatcher tool.

Examples

The following examples are copied from the procmailex man-page. Feel free to have a look into it (actually it is quite a good idea). Of course we changed the wording a bit (to fit it into the queueing idea).

Sort out all mail coming from the scuba-dive mailing list into the scuba queue.

    :0 fhw :
    * ^TOscuba
    | formail -I "X-OTRS-Queue: scuba"

Forward all mail from peter about compilers into the william queue.

    :0 fhw :
    * ^From.*peter
    * ^Subject:.*compilers
    | formail -I "X-OTRS-Queue: william"

And here a last example, the whole .procmailrc.

Example 7-2. .procmailrc

    # --
    # .procmailrc - procmailrc of the OTRS user
    # Copyright (C) 2001-2002 Martin Edenhofer (martin+code at otrs.org)
    # --
    # $Id: receiving_email.sgml,v 1.2 2004/09/04 22:26:39 martin Exp $
    # --
    # This software comes with ABSOLUTELY NO WARRANTY. For details, see
    # the enclosed file COPYING for license information (GPL). If you
    # did not receive this file, see http://www.gnu.org/licenses/gpl.txt.
    # --

    SYS_HOME=$HOME

    PATH=/bin:/usr/bin:/usr/local/bin
    MONTHFOLDER=`date +%Y-%m`
    YEARFOLDER=`date +%Y`
    LOGFILE=$SYS_HOME/var/log/procmail-$MONTHFOLDER.log
    VERBOSE=on

    # --
    # Remove all X-OTRS Header (allow this only for trusted email)
    # e. g. from *@example.com
    # --
    :0 fhw :
    * !^From.*@example.com
    | grep -vi '^X-OTRS-'

    # --
    # Examples for queue presorting.
    # --

    :0 fhw :
    * ^List-Id:.*OpenAntiVirus
    | formail -I "X-OTRS-Queue: OpenAntiVirus"

    :0 fhw :
    * ^Sender:.*example.com
    | formail -I "X-OTRS-Queue: example"

    :0 fhw :
    * TO:.*BUGTRAQ
    | formail -I "X-OTRS-Queue: BUGTRAQ"

    # --
    # Backup of all incoming emails.
    # It's always better to have a backup of all incoming emails!
    # --
    :0 c :
    $SYS_HOME/var/INBOX.Backup.$MONTHFOLDER

    # --
    # Pipe all email into the PostMaster process.
    # --
    :0 :
    | $SYS_HOME/bin/PostMaster.pl

    # --
    # spool all the rest (which the PostMaster.pl can't process!)
    # If the database is down or the PostMaster.pl exit was not '0'!
    # --
    :0 :
    $SYS_HOME/var/spool/.

    # --
    # end of .procmailrc
    # --

Please have a look into the procmailex man-page for more examples.

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

Prev | Home | Next
Filtering/dispatching by OTRS/PostMaster modules (for more complex dispatching) | Up | Example for filtering/dispatching by Procmail and a webform