blob: 546b792f5574923cbf2b02cb483e49c157f0d202 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# -*- mode: python; -*-
import subprocess
processor.maildir_base = "~/Maildir.purdue"
processor.auto_reload_rcfile = True
def is_to_or_from(mail,address):
"""
Return true if [mail] is to or from an address that contains [address].
"""
return (
mail["From"].contains(address)
or mail.target.contains(address))
def is_to_or_from_re(mail,address):
"""
Return true if [mail] is to or from an address that matches the
regex [address].
"""
return (
mail["From"].matches(address)
or mail.target.matches(address))
def handle_incoming_ham(mail):
my_filters(mail)
def handle_incoming_unknown(mail):
# Filter spam
spam = bogofilter_auto(mail)
if spam == 0:
handle_incoming_spam(mail)
return
elif spam == 1:
handle_incoming_ham(mail)
return
elif spam == 2:
# maybe spam
return
else:
mail.move(".Error")
return
def my_filters(mail):
if mail["Subject"].contains("[PASE]"):
mail.move("INBOX.PASE")
return
if mail["Subject"].contains("[PLUG]"):
mail.move("INBOX.PLUG")
return
if mail["Subject"].contains("Fall-2012-SCI-21000-001:"):
mail.move("INBOX.classes.SCI210")
if (
False
or mail["Subject"].contains("[CS Opportunity Update]")
or mail["Subject"].contains("[CS Majors]")
):
mail.move("INBOX.CS")
return
if is_to_or_from(mail,"linkedin.com"):
mail.move("INBOX.LinkedIn")
return
if mail["Subject"].contains("fall-2012-cs-18000"):
mail.move("INBOX.classes.CS180")
return
if (
False
or is_to_or_from(mail,"CS 18000 on Piazza")
or mail["Subject"].contains("CS 18000 on Piazza")
):
mail.move("INBOX.classes.CS180.Piazza")
return
if mail["Subject"].contains("Fall-2012-SOC-10000"):
mail.move("INBOX.classes.SOC100")
return
handle_mapping = {
"INBOX": handle_incoming_ham,
}
processor.maildirs = handle_mapping.keys()
for mail in processor:
handle_mapping[mail.maildir](mail)
|