Commit e4bd4c8a218a

Vincent Demeester <vincent@sbr.pm>
2026-01-15 09:58:28
fix(mail): Fix goimapnotify port handling and iCloud trash folder
- Handle null IMAP port values in goimapnotify config (defaults to 993) This fixes connection timeouts caused by port: 0 in generated config - Update imapfilter to use correct iCloud trash folder "Deleted Messages" instead of "Trash" for proper sync with iOS Mail (Bin) and macOS Mail Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 7eecfc3
Changed files (2)
home/common/services/goimapnotify.nix
@@ -6,9 +6,14 @@
 }:
 let
   # Helper function to create goimapnotify config for an account
-  mkAccountConfig = accountName: accountConfig: ''
+  mkAccountConfig = accountName: accountConfig:
+    let
+      # Handle null port values - if port is null or not set, use 993
+      imapPort = if accountConfig.imap.port != null then accountConfig.imap.port else 993;
+    in
+    ''
     host: ${accountConfig.imap.host}
-    port: ${toString (accountConfig.imap.port or 993)}
+    port: ${toString imapPort}
     tls: true
     tlsOptions:
       rejectUnauthorized: true
@@ -28,7 +33,7 @@ let
       else
         ${pkgs.mu}/bin/mu index --quiet
       fi
-  '';
+    '';
 
   # Get enabled email accounts that have mbsync enabled
   enabledAccounts = builtins.filter (
home/common/services/imapfilter-config.lua
@@ -167,9 +167,9 @@ function apply_rules(messages, rules, action, folder_name)
 	if #results > 0 then
 		print(string.format("  → Matched %d message(s)", #results))
 		if action == 'delete' then
-			-- Move to Trash instead of permanent deletion
-			account:create_mailbox('Trash')
-			results:move_messages(account['Trash'])
+			-- Move to Deleted Messages (iCloud's trash folder, shows as "Bin" in iOS)
+			account:create_mailbox('Deleted Messages')
+			results:move_messages(account['Deleted Messages'])
 		elseif action == 'archive' then
 			archive_by_year(results)
 		elseif action == 'move' then