From 9934dd538b0ce116e3b1600272cb46369b082246 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Wed, 2 Feb 2022 13:34:47 +0800 Subject: init commit --- dovecot/sieve | 149 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 dovecot/sieve (limited to 'dovecot/sieve') diff --git a/dovecot/sieve b/dovecot/sieve new file mode 100644 index 0000000..b11f1cc --- /dev/null +++ b/dovecot/sieve @@ -0,0 +1,149 @@ +# Sieve filter + +# Declare the extensions used by this script. +require ["fileinto", "reject", "variables", "editheader"]; + +# If transport is not encrypted, add warning emoji at the beginning of the subject +if header :contains "Received" ["by topo.tw (Postfix) with ESMTP "] +{ + # Match the entire subject + if header :matches "Subject" "*" { + # Stored in a variable: + set "subject" "${1}"; + } + deleteheader "Subject"; + addheader :last "Subject" "⚠ ${subject}"; +} + +# Edit header for test +if header :contains "From" ["typebrook@gmail.com"] { + # Match the entire subject ... + if header :matches "Subject" "*" { + # ... to get it in a match group that can then be stored in a variable: + set "subject" "${1}"; + } + deleteheader "Subject"; + addheader :last "Subject" "Warning: ${subject}"; +} + +# CAUTION!! +# Put this block at the top so unwanted mail are discarded +# Message which will trigger commands +# Discard them so we only have message in Sent +if allof ( + address :is ["To"] "mastodon@topo.tw", + header :matches "X-Original-To" "mastodon@topo.tw" +) { + discard; +} + +elsif header :contains "From" [ + "HANCHOR", + "info@members.netflix.com", + "Amazon Web Services", + "no-reply@wamazing.jp", + "info@join.netflix.com", + "noreply@steampowered.com" +] { + fileinto "promotion"; +} + +elsif header :matches :comparator "i;ascii-casemap" "Subject" [ + "*login*", + "*verify*", + "*sign-in*", + "*登入*", + "*密碼*", + "*安全性警示*", + "*new IP Address*" +] { + fileinto "login"; +} + +elsif header :matches :comparator "i;ascii-casemap" "Subject" [ + "*系統公告*" +] { + fileinto "service"; +} + +elsif header :contains :comparator "i;ascii-casemap" "Subject" [ + "帳單", + "付款", + "繳款", + "扣款", + "交易", + "費用", + "eGUI", + "Invoice", + "發票", + "Receipt", + "Billing", + "Expense" +] { + fileinto "pay"; +} + +elsif header :matches :comparator "i;ascii-casemap" "Subject" ["*永豐*"] { + fileinto "STOCK"; +} + +elsif address :is ["From"] "no-reply@hackmd.io" { + fileinto "update"; +} + +elsif address :is ["From"] "notifications@github.com" { + fileinto "github"; +} + +elsif address :contains ["To", "Cc"] "arch-general@lists.archlinux.org" { + fileinto "mailing_list.arch-general"; +} + +elsif address :is ["From", "To", "Cc"] "mutt-users@mutt.org" { + fileinto "mailing_list.mutt-users"; +} + +elsif address :is ["From", "To", "Cc"] "help-bash@gnu.org" { + fileinto "mailing_list.bash"; +} + +elsif header :matches "Sender" "*~rjarry/aerc-discuss@lists.sr.ht*" { + fileinto "mailing_list.aerc"; +} + +elsif header :matches "Chat-Version" ["*"] { + fileinto "DeltaChat"; +} + +elsif header :matches "X-Original-To" ["cybersec@topo.tw"] { + fileinto "cybersec"; +} + +elsif address :is ["To"] "lay9412206@gmail.com" { + fileinto "hometeach"; +} + +# Spam Rule: +# Message does not contain my address in "To", "CC" or "BCC" +elsif anyof ( + not header :contains ["To", "Cc", "Bcc", "X-Original-To"] "topo.tw", + header :contains "X-Original-To" "eocuk17" +) { + fileinto "spam"; +} +# Or fake header in "From" +elsif allof ( + header :matches "From" "*@topo.tw*", + not header :contains "Received" [ + "from topo.tw", + "from PC", + "from [127.0.0.1]", + "by topo.tw" + ] +) { + fileinto "spam"; +} + +else { + fileinto "INBOX"; +} -- cgit v1.2.3-70-g09d2