Procmail Rules to filter some Spam

From froelix.com - Wiki
Jump to: navigation, search

Following there is an example of the .procmailrc configuration file. This example filters Spam mails based on some keywords and moves them to the Spam directory.

For detailed information regarding the Procmail syntax, see Procmail Quick Reference Guide.

LOGFILE=procmail.log

########################################
# SPAMASSASSIN
########################################

#:0fw
#| /usr/bin/spamassassin

# Header=* ^X-Spam-Level: \*\*\*\*\*\*\*\*\*\* - verschieben nach Junk
#:0 H
#* ^X-Spam-Level: \*\*
#$HOME/mail/Junk

# Nachrichten mit SPAM-Score >= 2 in den Mailordner SPAM verschieben
#:0 H
#* ^X-Spam-Score:.*\(\*\*
#$HOME/mail/Junk

# Header=* ^X-Spam-Status: Yes - verschieben nach Junk
#:0 H
#* ^X-Spam-Status: Yes
#$HOME/mail/Junk

########################################

########################################
# CALCULATE SIZES
########################################

# Count Body Size
:0
* 1^1 B ?? > 1
{ }
size = $=
#:0 fhw
#* ! ^Body-Size:
#| $FORMAIL -a "Body-Size: $size"

# Count Body Lines
:0 B
* 1^1 B ?? ^.*$
* -1^0
{ }
lines = $=
#:0 fhw
#* ! ^Body-Lines:
#| $FORMAIL -a "Body-Lines: $lines"

########################################

########################################
# MARK SPAM
########################################

# Spam: Stocks
:0 Bfhw
* .*(trade|trading|stock|equities|share).*
* .*(\$|dollar|price|pricing|target|money|cost).*
| $FORMAIL -i "X-Spam-Type: stocks

# Spam: Schufa Kredit
:0 Bfhw
* .*redit.*
* .*schufa.*
* .*http://.*
| $FORMAIL -i "X-Spam-Type: kredit

# Spam: Versicherung
:0 Bfhw
* .*versicherung.*
* .*http://.*
| $FORMAIL -i "X-Spam-Type: versicherung

# Spam: Casino
:0 Bfhw
* .*asino.*
* .*(geld|cash|gaming).*
* .*http://.*
| $FORMAIL -i "X-Spam-Type: casino

#Spam: 1 Zeile + Link
:0 Bfhw
* $lines ?? ^^[012]^^
* .*http://.*
| $FORMAIL -i "X-Spam-Type: short with link, $lines lines, size $size"

########################################

########################################
# FILTER SPAM
########################################

# Header=* ^X-Spam-Type: - verschieben nach Junk
:0 H
* ^X-Spam-Type:
* ! ^X-KasSpamfilter: Whitelist
$HOME/mail/Junk

########################################