From: martin f. krafft Date: Sun, 23 Sep 2007 16:59:49 +0000 (+0200) Subject: make all deliveries happen late X-Git-Url: https://git.madduck.net/etc/mailfilter.git/commitdiff_plain/0f4bcee75353935ff9bc605f7e0b31d12e302605 make all deliveries happen late --- diff --git a/procmail/deliver b/procmail/deliver index c3188ff..5a4f355 100644 --- a/procmail/deliver +++ b/procmail/deliver @@ -1,30 +1,26 @@ :0 -* DEST ?? . -{ - :0 - * DEST ?? .+[^/]$ - { DEST="$DEST/" } +* ! DEST ?? . +{ DEST="$DEFAULT" } - :0 - *$ DEST ?? ^$BASE/\/.+ - { DEST="$MATCH" } - - :0 - *$ DEST ?? ^\. - { } +:0 +* DEST ?? .+[^/]$ +{ DEST="$DEST/" } - :0 E - { DEST=".$DEST" } +:0 +*$ DEST ?? ^$BASE/\/.+ +{ DEST="$MATCH" } - LOG="deliver: delivering message $MSGID to $DEST$NL" - DEST="$BASE/$DEST" - :0 - $DEST -} +:0 +*$ DEST ?? ^\. +{ } :0 E -{ - LOG="deliver: delivering message $MSGID to default destination$NL" - :0 - $DEFAULT -} +{ DEST=".$DEST" } + +TRAP="DEST=\"\${LASTFOLDER#$BASE/}\"; + echo \"delivered: \$DEST\" >> '$THISLOGFILE'; + $TRAP" + +LOG="deliver: delivering message $MSGID to $DEST$NL" +:0 +$BASE/$DEST diff --git a/procmail/handlespam b/procmail/handlespam index cab35eb..233234a 100644 --- a/procmail/handlespam +++ b/procmail/handlespam @@ -34,7 +34,7 @@ { LOG="spamfilter: filing as unsure$NL" :0 - $BASE/.retrain.unsure/ + { DEST=retrain.unsure } } :0 E @@ -42,7 +42,7 @@ { LOG="spamfilter: filing as disagreed$NL" :0 - $BASE/.retrain.disagree/ + { DEST=retrain.disagree } } :0 E @@ -70,7 +70,7 @@ { LOG="spamfilter: filing as spam$NL" :0 - $BASE/.spam/ + { DEST=spam } } :0 diff --git a/procmail/listquirks b/procmail/listquirks index ea729a8..6ceeb00 100644 --- a/procmail/listquirks +++ b/procmail/listquirks @@ -5,6 +5,7 @@ # send-hook '~C git@vger\.kernel\.org' 'unset followup_to' # :0 +* ! DEST ?? . * ? echo "$EQ_TO" | $EGREP -qif $CONF/cclists * ! ^Mail-Followup-To: { diff --git a/procmail/logging b/procmail/logging index d812032..38b901a 100644 --- a/procmail/logging +++ b/procmail/logging @@ -20,9 +20,7 @@ from: $FROM original-to: $ORIGINAL_TO subject: $SUBJECT$NL" -TRAP="DEST=\"\${LASTFOLDER#$BASE/}\"; - echo \"delivered: \$DEST\" >> '$THISLOGFILE'; - echo >> '$THISLOGFILE'; +TRAP="echo >> '$THISLOGFILE'; egrep -v '^XX(procmail:)?[[:space:]\"]' '$THISLOGFILE' >> $MASTERLOGFILE" #VERBOSE=yes diff --git a/procmail/procmailrc b/procmail/procmailrc index 6afe20c..93b6235 100755 --- a/procmail/procmailrc +++ b/procmail/procmailrc @@ -31,12 +31,8 @@ INCLUDERC=$PMDIR/to-gmail INCLUDERC=$PMDIR/justme -INCLUDERC=$PMDIR/spamtraps -INCLUDERC=$PMDIR/spammers INCLUDERC=$PMDIR/spamfilter -INCLUDERC=$PMDIR/addheaders - INCLUDERC=$PMDIR/handlespam #INCLUDERC=$PMDIR/autoreplies @@ -49,4 +45,5 @@ INCLUDERC=$PMDIR/listquirks INCLUDERC=$PMRULES/all +INCLUDERC=$PMDIR/addheaders INCLUDERC=$PMDIR/deliver diff --git a/procmail/rules/admin b/procmail/rules/admin index 0fcf767..2873572 100644 --- a/procmail/rules/admin +++ b/procmail/rules/admin @@ -13,7 +13,7 @@ } :0 - $BASE/.admin/ + { DEST=admin } # DESTDIR="$BASE/.admin.`echo $EQ_DOMAIN | tr . _" # diff --git a/procmail/rules/all b/procmail/rules/all index 456e55b..a8b24da 100644 --- a/procmail/rules/all +++ b/procmail/rules/all @@ -1,8 +1,12 @@ -INCLUDERC=$PMRULES/feeds -INCLUDERC=$PMRULES/admin -INCLUDERC=$PMRULES/ul -INCLUDERC=$PMRULES/debian -INCLUDERC=$PMRULES/sudetia -INCLUDERC=$PMRULES/mass +:0 +* ! DEST ?? . +{ + INCLUDERC=$PMRULES/feeds + INCLUDERC=$PMRULES/admin + INCLUDERC=$PMRULES/ul + INCLUDERC=$PMRULES/debian + INCLUDERC=$PMRULES/sudetia + INCLUDERC=$PMRULES/mass +} # vim:ft=procmail diff --git a/procmail/rules/debian b/procmail/rules/debian index f5442e9..4c6330d 100644 --- a/procmail/rules/debian +++ b/procmail/rules/debian @@ -1,22 +1,22 @@ :0 * ^X-Debian-PR-Source: \/.+ * ? grep -q "^${MATCH}$" $CONF/debian-packages -$BASE/.debian.$MATCH/ +{ DEST=debian.$MATCH } :0 * ORIGINAL_TO ?? ^logcheck-(devel|commits)=lists\.alioth\.debian\.org@mass\.madduck\.net$ -$BASE/.debian.logcheck/ +{ DEST=debian.logcheck } :0 * ORIGINAL_TO ?? ^pkg-mdadm-(devel|commits)=lists\.alioth\.debian\.org@mass\.madduck\.net$ -$BASE/.debian.mdadm/ +{ DEST=debian.mdadm } :0 * ORIGINAL_TO ?? ^netconf-(devel|commits)=lists\.alioth\.debian\.org@mass\.madduck\.net$ -$BASE/.debian.netconf/ +{ DEST=debian.netconf } :0 * ORIGINAL_TO ?? ^madduck=debian\.org@forward\.madduck\.net$ -$BASE/.debian/ +{ DEST=debian } # vim:ft=procmail diff --git a/procmail/rules/feeds b/procmail/rules/feeds index 5f17bd6..bb653a6 100644 --- a/procmail/rules/feeds +++ b/procmail/rules/feeds @@ -1,10 +1,5 @@ :0 * ORIG_DOMAIN ?? ^r2e\.madduck\.net$ -{ - DESTDIR=$BASE/.feeds - - :0 - ${DESTDIR}/ -} +{ DEST=feeds } # vim:ft=procmail diff --git a/procmail/rules/mass b/procmail/rules/mass index 59b6bd3..35aa48d 100644 --- a/procmail/rules/mass +++ b/procmail/rules/mass @@ -1,10 +1,5 @@ :0 * ORIG_DOMAIN ?? ^mass\.madduck\.net$ -{ - DESTDIR=$BASE/.mass - - :0 - ${DESTDIR}/ -} +{ DEST=mass } # vim:ft=procmail diff --git a/procmail/rules/sudetia b/procmail/rules/sudetia index 28e4e32..3ce55b4 100644 --- a/procmail/rules/sudetia +++ b/procmail/rules/sudetia @@ -1,5 +1,5 @@ :0 * ORIGINAL_TO ?? ^m(artin\.)?krafft@sudetia\.de$ -$BASE/.sudetia/ +{ DEST=sudetia } # vim:ft=procmail diff --git a/procmail/rules/ul b/procmail/rules/ul index e88e8f9..a2b1d89 100644 --- a/procmail/rules/ul +++ b/procmail/rules/ul @@ -17,7 +17,7 @@ RE_UL_DOMAIN :0 - $BASE/.ul/ + { DEST=ul } } # vim:ft=procmail diff --git a/procmail/spamfilter b/procmail/spamfilter index 9e88642..37c3c33 100755 --- a/procmail/spamfilter +++ b/procmail/spamfilter @@ -46,6 +46,14 @@ PMDIR=${PMDIR:-$HOME/.etc/mailfilter/procmail} { LOG="spamfilter: skipping resubmitted message$NL" } } +# do not run spamfilters if the message destination is already set +:0 E +* DEST ?? . +{ + LOG="spamfilter: message already routed to '$DEST'$NL" + SPAM_UNKNOWN=already-destined +} + # let earlier parts of the mailfilter cause bypassing the checks :0 E * SKIP_SPAMCHECKS ?? . @@ -81,6 +89,8 @@ PMDIR=${PMDIR:-$HOME/.etc/mailfilter/procmail} # now run the spamfilters :0 E { + INCLUDERC=$PMDIR/spamtraps + INCLUDERC=$PMDIR/spammers INCLUDERC=$PMDIR/pre-spam-cleanup # crm114 diff --git a/procmail/tickle b/procmail/tickle index 672358d..363efb7 100644 --- a/procmail/tickle +++ b/procmail/tickle @@ -1,4 +1,5 @@ :0 +* ! DEST ?? . * ORIGINAL_TO ?? ^.+@tickle\.madduck\.net$ * ORIGINAL_TO ?? ^\/[^@]+ { diff --git a/procmail/to-gmail b/procmail/to-gmail index e73c8f1..59df5cc 100644 --- a/procmail/to-gmail +++ b/procmail/to-gmail @@ -7,7 +7,7 @@ { LOG="gmail: archiving message $MSGID with gmail$NL" SENDMAILFLAGS="$SENDMAILFLAGS -f $ID" - TRAP="" + TRAP :0 ! martin.krafft@gmail.com