]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Add automatic backup of received e-mails
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Sun, 17 Nov 2019 13:47:58 +0000 (14:47 +0100)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Sun, 17 Nov 2019 13:47:58 +0000 (14:47 +0100)
modules/private/mail/dovecot.nix
modules/private/mail/sieve_scripts/backup.sieve [new file with mode: 0644]

index 6c3b4b8e14660e5087718277d4810f08592128ed..f52f26352022642aa7228a6651cc80663b3f0b8f 100644 (file)
@@ -92,6 +92,17 @@ in
           }
         ''
 
+        # ACL
+        ''
+          mail_plugins = $mail_plugins acl
+          plugin {
+            acl = vfile:${pkgs.writeText "dovecot-acl" ''
+              Backup/* owner lrp
+              ''}
+            acl_globals_only = yes
+          }
+        ''
+
         # Full text search
         ''
           # needs to be bigger than any mailbox size
@@ -117,6 +128,8 @@ in
             sieve_plugins = sieve_imapsieve sieve_extprograms
             imapsieve_url = sieve://127.0.0.1:4190
 
+            sieve_before = file:${./sieve_scripts}/backup.sieve
+
             # From elsewhere to Junk folder
             imapsieve_mailbox1_name = Junk
             imapsieve_mailbox1_causes = COPY APPEND
@@ -225,7 +238,7 @@ in
         # Needs to come last if there are mail_plugins entries
         ''
         protocol imap {
-          mail_plugins = $mail_plugins imap_sieve
+          mail_plugins = $mail_plugins imap_sieve imap_acl
         }
         protocol lda {
           mail_plugins = $mail_plugins sieve
diff --git a/modules/private/mail/sieve_scripts/backup.sieve b/modules/private/mail/sieve_scripts/backup.sieve
new file mode 100644 (file)
index 0000000..c922999
--- /dev/null
@@ -0,0 +1,9 @@
+# vim: filetype=sieve
+require ["copy","mailbox","fileinto","regex"];
+if not header :regex "subject" "^TestMailImmae ?$" {
+  if header :is "X-Spam" "Yes" {
+    fileinto :create :copy "Backup/Spam";
+  } else {
+    fileinto :create :copy "Backup/Ham";
+  }
+}