{ pkgs, hostname, ... }: { home.packages = with pkgs; [ protonmail-bridge (writeShellScriptBin "protonmail-bridge-setup" '' systemctl --user stop protonmail-bridge ${protonmail-bridge}/bin/protonmail-bridge -c systemctl --user restart protonmail-bridge '') ]; accounts.email = { maildirBasePath = "Mail"; accounts = let realName = "Evie Litherland-Smith"; in { proton = let host = "127.0.0.1"; tls.enable = false; in rec { inherit realName; primary = true; maildir.path = "Proton"; imap = { inherit host tls; port = 1143; }; smtp = { inherit host tls; port = 1025; }; address = "e.litherlandsmith@proton.me"; aliases = ["evie@xenia.me.uk" "evie@litherlandsmith.slmail.me"]; userName = address; passwordCommand = "${pkgs.pass}/bin/pass show mbsync/${hostname}/proton | head -n1"; mu.enable = true; msmtp = { enable = true; extraConfig = { tls = "off"; auth = "login"; }; }; mbsync = { enable = true; create = "both"; expunge = "both"; remove = "both"; patterns = ["*" "!All Mail" "!Labels*" "!Starred" "!Recovered Messages"]; subFolders = "Verbatim"; extraConfig.account.AuthMechs = "LOGIN"; }; }; icloud = rec { inherit realName; primary = false; maildir.path = "iCloud"; imap.host = "imap.mail.me.com"; smtp.host = "smtp.mail.me.com"; address = "e.litherlandsmith@icloud.com"; userName = address; passwordCommand = "${pkgs.pass}/bin/pass show mbsync/${hostname}/icloud | head -n1"; mu.enable = true; msmtp.enable = true; mbsync = { enable = true; create = "both"; expunge = "both"; remove = "both"; patterns = ["*" "!Notes"]; subFolders = "Verbatim"; }; }; }; }; programs = { mu.enable = true; msmtp.enable = true; mbsync = { enable = true; groups.inboxes = { proton = ["INBOX"]; icloud = ["INBOX"]; }; }; }; systemd.user.services.protonmail-bridge = { Unit = { Description = "Proton Mail Bridge"; Wants = ["network-online.target"]; After = ["network-online.target"]; }; Service = { Environment = ["PATH=/run/current-system/sw/bin/:$PATH"]; Restart = "always"; ExecStart = "${pkgs.protonmail-bridge}/bin/protonmail-bridge -n"; }; Install.WantedBy = ["default.target"]; }; }