From 5e33119b147696794422ecbee035c17d7800c5eb Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Tue, 13 May 2025 15:21:06 +0100 Subject: [PATCH] feat: better sieve script --- applications/email.nix | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/applications/email.nix b/applications/email.nix index 72fd7ea..4808c35 100644 --- a/applications/email.nix +++ b/applications/email.nix @@ -106,10 +106,11 @@ with lib; let require ["fileinto", "reject"]; require "variables"; require "regex"; + require "subaddress"; # this should be close to teh last step if allof ( - address :localpart ["To", "Cc"] ["${toString create_config_to}"], + address :user ["To", "Cc"] ["${toString create_config_to}"], address :domain ["To", "Cc"] "skynet.ie" ){ if address :matches ["To", "Cc"] "*@skynet.ie" { @@ -118,12 +119,21 @@ with lib; let fileinto :create "''${1}.Spam_Report"; stop; } else { - if header :is "X-Spam" "Yes" { - fileinto :create "''${1}.Junk"; - stop; + # no detail, proceed normally + if address :detail ["To", "Cc"] "" { + if header :is "X-Spam" "Yes" { + fileinto :create "''${1}.Junk"; + stop; + } else { + fileinto :create "''${1}"; + stop; + } } else { - fileinto :create "''${1}"; - stop; + # user+subdir + if address :matches ["To", "Cc"] "*+*@skynet.ie" { + fileinto :create "''${1}.''${2}"; + stop; + } } } }