Filterung/Verteilung durch Procmail (für komplexere Verteilungsszenarien)

Falls Sie die PostMaster.pl Methode benutzen, können Sie X-OTRS-Header zur eMail hinzufügen und PostMaster.pl wird diesen Header dazu benutzen, die eMail an PostMaster.pl zu leiten. TODO: ergibt für mich keinen Sinn (postmaster.pl piped die Mail an sich selbst???)

Der X-OTRS-Queue Mail-Header

Der X-OTRS-Queue Mail-Header wird durch OTRS geprüft und OTRS wird eMails in die entsprechende Queue stellen. Procmail und fromail können dazu genutzt werden, ein mächtiges Verteilungs-Werkzeug zu erstellen.

Beispiele

Die folgenden Beispiele sind von procmailex man-page kopiert. Es ist eine gute Idee, sich diese einmal anzuschauen. Natürlich haben wir den Text ein wenig geändert (um es an die Queue-Idee anzupassen).

Alle eMails von der scuba-dive Maillingliste in die scuba Queue aussortieren.
:0 fhw :
* ^TOscuba
| formail -I "X-OTRS-Queue: scuba"
Alle eMails von Peter über Compiler an die william Queue weiterleiten
:0 fhw :
* ^From.*peter
* ^Subject:.*compilers
| formail -I "X-OTRS-Queue: william"
Und hier ein letztes Beispiel, die gesamte .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.5 2004/07/29 10:29:11 daniel 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
# --
Bitte schauen Sie in die procmailex man-page für mehr Beispiele.

Ausserdem gibt es eine Liste aller möglichen X-OTRS Header in doc/X-OTRS-Headers.txt.