summaryrefslogtreecommitdiffhomepage
path: root/dovecot/sieve
diff options
context:
space:
mode:
authorHsieh Chin Fan <typebrook@gmail.com>2022-02-02 13:34:47 +0800
committerHsieh Chin Fan <pham@topo.tw>2024-11-30 21:09:29 +0800
commit9934dd538b0ce116e3b1600272cb46369b082246 (patch)
tree2f28c6c362201151eaf8218e566479ed7eb72070 /dovecot/sieve
init commit
Diffstat (limited to 'dovecot/sieve')
-rw-r--r--dovecot/sieve149
1 files changed, 149 insertions, 0 deletions
diff --git a/dovecot/sieve b/dovecot/sieve
new file mode 100644
index 0000000..b11f1cc
--- /dev/null
+++ b/dovecot/sieve
@@ -0,0 +1,149 @@
1# Sieve filter
2
3# Declare the extensions used by this script.
4require ["fileinto", "reject", "variables", "editheader"];
5
6# If transport is not encrypted, add warning emoji at the beginning of the subject
7if header :contains "Received" ["by topo.tw (Postfix) with ESMTP "]
8{
9 # Match the entire subject
10 if header :matches "Subject" "*" {
11 # Stored in a variable:
12 set "subject" "${1}";
13 }
14 deleteheader "Subject";
15 addheader :last "Subject" "⚠ ${subject}";
16}
17
18# Edit header for test
19if header :contains "From" ["typebrook@gmail.com"] {
20 # Match the entire subject ...
21 if header :matches "Subject" "*" {
22 # ... to get it in a match group that can then be stored in a variable:
23 set "subject" "${1}";
24 }
25 deleteheader "Subject";
26 addheader :last "Subject" "Warning: ${subject}";
27}
28
29# CAUTION!!
30# Put this block at the top so unwanted mail are discarded
31# Message which will trigger commands
32# Discard them so we only have message in Sent
33if allof (
34 address :is ["To"] "mastodon@topo.tw",
35 header :matches "X-Original-To" "mastodon@topo.tw"
36) {
37 discard;
38}
39
40elsif header :contains "From" [
41 "HANCHOR",
42 "info@members.netflix.com",
43 "Amazon Web Services",
44 "no-reply@wamazing.jp",
45 "info@join.netflix.com",
46 "noreply@steampowered.com"
47] {
48 fileinto "promotion";
49}
50
51elsif header :matches :comparator "i;ascii-casemap" "Subject" [
52 "*login*",
53 "*verify*",
54 "*sign-in*",
55 "*登入*",
56 "*密碼*",
57 "*安全性警示*",
58 "*new IP Address*"
59] {
60 fileinto "login";
61}
62
63elsif header :matches :comparator "i;ascii-casemap" "Subject" [
64 "*系統公告*"
65] {
66 fileinto "service";
67}
68
69elsif header :contains :comparator "i;ascii-casemap" "Subject" [
70 "帳單",
71 "付款",
72 "繳款",
73 "扣款",
74 "交易",
75 "費用",
76 "eGUI",
77 "Invoice",
78 "發票",
79 "Receipt",
80 "Billing",
81 "Expense"
82] {
83 fileinto "pay";
84}
85
86elsif header :matches :comparator "i;ascii-casemap" "Subject" ["*永豐*"] {
87 fileinto "STOCK";
88}
89
90elsif address :is ["From"] "no-reply@hackmd.io" {
91 fileinto "update";
92}
93
94elsif address :is ["From"] "notifications@github.com" {
95 fileinto "github";
96}
97
98elsif address :contains ["To", "Cc"] "arch-general@lists.archlinux.org" {
99 fileinto "mailing_list.arch-general";
100}
101
102elsif address :is ["From", "To", "Cc"] "mutt-users@mutt.org" {
103 fileinto "mailing_list.mutt-users";
104}
105
106elsif address :is ["From", "To", "Cc"] "help-bash@gnu.org" {
107 fileinto "mailing_list.bash";
108}
109
110elsif header :matches "Sender" "*~rjarry/aerc-discuss@lists.sr.ht*" {
111 fileinto "mailing_list.aerc";
112}
113
114elsif header :matches "Chat-Version" ["*"] {
115 fileinto "DeltaChat";
116}
117
118elsif header :matches "X-Original-To" ["cybersec@topo.tw"] {
119 fileinto "cybersec";
120}
121
122elsif address :is ["To"] "lay9412206@gmail.com" {
123 fileinto "hometeach";
124}
125
126# Spam Rule:
127# Message does not contain my address in "To", "CC" or "BCC"
128elsif anyof (
129 not header :contains ["To", "Cc", "Bcc", "X-Original-To"] "topo.tw",
130 header :contains "X-Original-To" "eocuk17"
131) {
132 fileinto "spam";
133}
134# Or fake header in "From"
135elsif allof (
136 header :matches "From" "*@topo.tw*",
137 not header :contains "Received" [
138 "from topo.tw",
139 "from PC",
140 "from [127.0.0.1]",
141 "by topo.tw"
142 ]
143) {
144 fileinto "spam";
145}
146
147else {
148 fileinto "INBOX";
149}