From b9209a815c8c6f517641bd0974d0650c2514cfcf Mon Sep 17 00:00:00 2001
From: Julien Malka <julien@malka.sh>
Date: Thu, 26 Jan 2023 18:48:35 +0100
Subject: [PATCH] Trying advanced sieve thingies

---
 modules/mailserver/default.nix | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/modules/mailserver/default.nix b/modules/mailserver/default.nix
index 9ce50b3..df9eb64 100644
--- a/modules/mailserver/default.nix
+++ b/modules/mailserver/default.nix
@@ -23,6 +23,15 @@ with lib;
           "julien@malka.sh" = {
             hashedPasswordFile = "/run/secrets/malkash-pw";
             catchAll = [ "malka.sh" ];
+            sieveScript = ''
+              require ["variables", "fileinto", "envelope", "subaddress", "mailbox"];
+
+              if envelope :matches :user "to" "*" {
+                # you can prefix with INBOX/ or INBOX. if necessary
+                # remove :create if you want to permit only existing mailboxes
+                fileinto :create "''${1}";
+              }
+            '';
           };
           "julien.malka@ens.school" = {
             hashedPasswordFile = "/run/secrets/ensmailmalka-pw";