Procmail: Unterschied zwischen den Versionen

Aus crazylinux.de
Zur Navigation springen Zur Suche springen
(sendmail)
(samples)
 
(4 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 10: Zeile 10:
DOMHOME="$VPOPHOME/domains/$DOM"
DOMHOME="$VPOPHOME/domains/$DOM"
USERHOME="$DOMHOME/$USERNAME"
USERHOME="$DOMHOME/$USERNAME"
SENDMAIL="/usr/sbin/sendmail -f $USERNAME@$DOM"
SENDMAIL="/usr/sbin/sendmail -f $USERNAME@$DOM"


 
DEFAULT="$USERHOME/Maildir/"
DEFAULT="$USERHOME/Maildir"
HOME="$USERHOME"
HOME="$USERHOME"
INCLUDERC="$USERHOME/.procmailrc"
INCLUDERC="$USERHOME/.procmailrc"
##### move_Spam #####
:0
* ^X-Spam-Status:.*Yes
"$DEFAULT/.Spam/"
##### move_unknown #####
:0
* ^X-Spam-Level:.*++
"$DEFAULT/.Unknown/"


:0 w
:0 w
Zeile 28: Zeile 36:
VPOPMAIL=`echo ~vpopmail`
VPOPMAIL=`echo ~vpopmail`
DOMDIR=`$VPOPMAIL/bin/vdominfo -d $HOST`
DOMDIR=`$VPOPMAIL/bin/vdominfo -d $HOST`
#convert to lower
EXT=`echo $EXT | tr "[:upper:]" "[:lower:]" `;
#check, if maildir exist
if [ -d $DOMDIR/$EXT/Maildir ]; then
        #create spamfolder if not exists
        if [ ! -d $DOMDIR/$EXT/Maildir/.Spam ]; then
                /usr/bin/maildirmake.courier -f Spam $DOMDIR/$EXT/Maildir/
                cat > /dev/null
        fi
        #create unknownfolder if not exists
        if [ ! -d $DOMDIR/$EXT/Maildir/.Unknown ]; then
                /usr/bin/maildirmake.courier -f Unknown $DOMDIR/$EXT/Maildir/
                cat > /dev/null
        fi
        #create subscription or subscribe to spamfolder
        if [ ! -r $DOMDIR/$EXT/Maildir/courierimapsubscribed ]; then
                `echo INBOX.Spam>>$DOMDIR/$EXT/Maildir/courierimapsubscribed`;
        else
                #exist the subscription?
                if [ `/bin/grep Spam $DOMDIR/$EXT/Maildir/courierimapsubscribed |wc -l` = 0 ]; then
                        `echo INBOX.Spam>>$DOMDIR/$EXT/Maildir/courierimapsubscribed`;
                fi
        fi
        #create subscription or subscribe to unknownfolder
        if [ ! -r $DOMDIR/$EXT/Maildir/courierimapsubscribed ]; then
                `echo INBOX.Unknown>>$DOMDIR/$EXT/Maildir/courierimapsubscribed`;
        else
                #exist the subscription?
                if [ `/bin/grep Unknown $DOMDIR/$EXT/Maildir/courierimapsubscribed |wc -l` = 0 ]; then
                        `echo INBOX.Unknown>>$DOMDIR/$EXT/Maildir/courierimapsubscribed`;
                fi
        fi
fi


if [ -r $DOMDIR/$EXT/.procmailrc ]; then
if [ -r $DOMDIR/$EXT/.procmailrc ]; then
Zeile 33: Zeile 79:
         cat > /dev/null
         cat > /dev/null
         exit 99
         exit 99
else
        env -i DOM=$HOST USERNAME=$EXT /usr/bin/procmail -p -m /etc/procmailrc
        cat > /dev/null
fi
fi
cat > /dev/null
cat > /dev/null
Zeile 45: Zeile 94:
| /var/qmail/bin/preline /usr/sbin/preprocmail
| /var/qmail/bin/preline /usr/sbin/preprocmail
| /var/vpopmail/bin/vdelivermail '' bounce-no-mailbox
| /var/vpopmail/bin/vdelivermail '' bounce-no-mailbox
<pre>
</pre>
 
==Links==
[http://www.huschi.net/11_203_de.html Beispiele für Filterung]


[[Category:Mail]]
[[Category:Mail]]

Aktuelle Version vom 26. Februar 2007, 22:12 Uhr

Procmail ist ein Mailfilter mit dem man z.b. Spam- oder Maillinglistenmails automatisch in ein Unterordner verschieben kann. Filterregeln können mit Horde(Ingo) erstellt werden.
von http://www.qmailinfo.org/index.php/Horde-Procmail-Filters

/etc/procmailrc:

SHELL="/bin/sh"
#LOGFILE="/tmp/procmail.log"
#VERBOSE=on
VPOPHOME="/var/vpopmail"
DOMHOME="$VPOPHOME/domains/$DOM"
USERHOME="$DOMHOME/$USERNAME"
SENDMAIL="/usr/sbin/sendmail -f $USERNAME@$DOM"

DEFAULT="$USERHOME/Maildir/"
HOME="$USERHOME"
INCLUDERC="$USERHOME/.procmailrc"

##### move_Spam #####
:0
* ^X-Spam-Status:.*Yes
"$DEFAULT/.Spam/"

##### move_unknown #####
:0
* ^X-Spam-Level:.*++
"$DEFAULT/.Unknown/"

:0 w
| /usr/bin/safecat "${HOME}/Maildir/tmp" "${HOME}/Maildir/new"

/usr/sbin/preprocmail:

#!/bin/sh

VPOPMAIL=`echo ~vpopmail`
DOMDIR=`$VPOPMAIL/bin/vdominfo -d $HOST`

#convert to lower
EXT=`echo $EXT | tr "[:upper:]" "[:lower:]" `;

#check, if maildir exist
if [ -d $DOMDIR/$EXT/Maildir ]; then
        #create spamfolder if not exists
        if [ ! -d $DOMDIR/$EXT/Maildir/.Spam ]; then
                /usr/bin/maildirmake.courier -f Spam $DOMDIR/$EXT/Maildir/
                cat > /dev/null
        fi

        #create unknownfolder if not exists
        if [ ! -d $DOMDIR/$EXT/Maildir/.Unknown ]; then
                /usr/bin/maildirmake.courier -f Unknown $DOMDIR/$EXT/Maildir/
                cat > /dev/null
        fi

        #create subscription or subscribe to spamfolder
        if [ ! -r $DOMDIR/$EXT/Maildir/courierimapsubscribed ]; then
                `echo INBOX.Spam>>$DOMDIR/$EXT/Maildir/courierimapsubscribed`;
        else
                #exist the subscription?
                if [ `/bin/grep Spam $DOMDIR/$EXT/Maildir/courierimapsubscribed |wc -l` = 0 ]; then
                        `echo INBOX.Spam>>$DOMDIR/$EXT/Maildir/courierimapsubscribed`;
                fi
        fi

        #create subscription or subscribe to unknownfolder
        if [ ! -r $DOMDIR/$EXT/Maildir/courierimapsubscribed ]; then
                `echo INBOX.Unknown>>$DOMDIR/$EXT/Maildir/courierimapsubscribed`;
        else
                #exist the subscription?
                if [ `/bin/grep Unknown $DOMDIR/$EXT/Maildir/courierimapsubscribed |wc -l` = 0 ]; then
                        `echo INBOX.Unknown>>$DOMDIR/$EXT/Maildir/courierimapsubscribed`;
                fi
        fi
fi

if [ -r $DOMDIR/$EXT/.procmailrc ]; then
        env -i DOM=$HOST USERNAME=$EXT /usr/bin/procmail -p -m /etc/procmailrc
        cat > /dev/null
        exit 99
else
        env -i DOM=$HOST USERNAME=$EXT /usr/bin/procmail -p -m /etc/procmailrc
        cat > /dev/null
fi
cat > /dev/null
exit 0


This script will be called from a .qmail file. For example,

/var/vpopmail/domains/somedomain.com/.qmail-default:

| /var/qmail/bin/preline /usr/sbin/preprocmail
| /var/vpopmail/bin/vdelivermail '' bounce-no-mailbox

Links

Beispiele für Filterung