aboutsummaryrefslogtreecommitdiffstats
path: root/roles/mail/files
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2018-03-05 22:50:50 +0800
committerAaron LI <aly@aaronly.me>2018-03-14 11:35:08 +0800
commitddc53fbccc185bc52adf1050a98531c3750bf1fd (patch)
treee44662ce7e67655e28a248bb72b083a92c781e8e /roles/mail/files
parentfb9e90d84ab1eb50c6f0702316a67bcad6db8524 (diff)
downloadansible-dfly-vps-ddc53fbccc185bc52adf1050a98531c3750bf1fd.tar.bz2
mail: setup dovecot sevice
Diffstat (limited to 'roles/mail/files')
-rw-r--r--roles/mail/files/sieve/README24
-rw-r--r--roles/mail/files/sieve/after.d/50-spam.sieve32
-rw-r--r--roles/mail/files/sieve/after.d/51-msgid.sieve22
3 files changed, 78 insertions, 0 deletions
diff --git a/roles/mail/files/sieve/README b/roles/mail/files/sieve/README
new file mode 100644
index 0000000..b004418
--- /dev/null
+++ b/roles/mail/files/sieve/README
@@ -0,0 +1,24 @@
+This directory contains the global Sieve scripts:
+
+* before.d : scripts executed before the user's personal script;
+* after.d : scripts executed after the user's personal script.
+
+Most scripts are placed to the "after.d" location, thus enable user to
+easily overwrite the system/global defaults.
+
+NOTE:
+* These Sieve scripts should have the proper ".sieve" extension.
+* These Sieve scripts should been manually compiled, due to the lack of
+ write permission for the caller process:
+ $ sievec before.d
+ $ sievec after.d
+
+See:
+* https://wiki.dovecot.org/Pigeonhole/Sieve
+* https://wiki.dovecot.org/Pigeonhole/Sieve/Configuration
+* https://wiki.dovecot.org/Pigeonhole/Sieve/Usage
+* https://wiki.dovecot.org/Pigeonhole/Sieve/Examples
+
+
+Aaron LI
+2017-04-25
diff --git a/roles/mail/files/sieve/after.d/50-spam.sieve b/roles/mail/files/sieve/after.d/50-spam.sieve
new file mode 100644
index 0000000..3d48337
--- /dev/null
+++ b/roles/mail/files/sieve/after.d/50-spam.sieve
@@ -0,0 +1,32 @@
+#
+# /usr/local/etc/dovecot/sieve/after.d/50-spam.sieve
+#
+# Global filters to filter spams.
+#
+# See: https://wiki.dovecot.org/Pigeonhole/Sieve
+#
+# Aaron LI
+# 2017-04-24
+#
+
+
+# fileinto: place messages into an IMAP folder other than INBOX
+require "fileinto";
+# mailbox: create the IMAP folder if not exists
+require "mailbox";
+# imap4flags: add IMAP flags to stored messages
+require "imap4flags";
+
+
+# Just delete spams higher than level 10!
+if header :contains "X-Spam-Level" "**********" {
+ discard;
+ stop;
+}
+
+# Move SpamAssassin-tagged mails to "Junk" folder.
+if header :contains "X-Spam-Flag" "YES" {
+ fileinto :create "Junk";
+ setflag "\\Seen";
+ stop;
+}
diff --git a/roles/mail/files/sieve/after.d/51-msgid.sieve b/roles/mail/files/sieve/after.d/51-msgid.sieve
new file mode 100644
index 0000000..ea0e55d
--- /dev/null
+++ b/roles/mail/files/sieve/after.d/51-msgid.sieve
@@ -0,0 +1,22 @@
+#
+# /usr/local/etc/dovecot/sieve/after.d/51-msgid.sieve
+#
+# Global filters to filter messages with invalid "message-id".
+#
+# Aaron LI
+# 2017-04-24
+#
+
+
+require "fileinto";
+require "mailbox";
+require "imap4flags";
+require "regex";
+
+
+# Trash messages with improperly formed "message-id"
+if not header :regex "message-id" ".*@.*\\." {
+ fileinto :create "Trash";
+ setflag "\\Seen";
+ stop;
+}