From d66cf000b08c6cdfbad1e118c292b46505f07168 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Fri, 29 Jul 2022 08:28:57 +0200 Subject: [PATCH] mail: Add tu-dreden account Special thanks to whoever thought that a backslash in a user name is a good idea. --- users/simon/modules/mail/accounts.nix | 27 +++++++++++++++++++++++ users/simon/modules/mail/aerc/default.nix | 9 ++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/users/simon/modules/mail/accounts.nix b/users/simon/modules/mail/accounts.nix index 3455ba1..b97a37c 100644 --- a/users/simon/modules/mail/accounts.nix +++ b/users/simon/modules/mail/accounts.nix @@ -78,6 +78,33 @@ in signature.text = signaturePersonal; + aerc.enable = true; + }; + tu-dresden = rec { + realName = "Simon Bruder"; + address = "simon.bruder@mailbox.tu-dresden.de"; + + userName = "user\\sibr833e"; + passwordCommand = "pass web/tu-dresden.de | head -n 1"; + + imap = { + host = "msx.tu-dresden.de"; + tls.useStartTls = true; + }; + smtp = { + host = "msx.tu-dresden.de"; + port = 587; + tls.useStartTls = true; + }; + + gpg = { + key = config.programs.gpg.settings.default-key; + signByDefault = true; + encryptByDefault = true; + }; + + signature.text = signaturePersonal; + aerc.enable = true; }; }; diff --git a/users/simon/modules/mail/aerc/default.nix b/users/simon/modules/mail/aerc/default.nix index aedfbdf..297e203 100644 --- a/users/simon/modules/mail/aerc/default.nix +++ b/users/simon/modules/mail/aerc/default.nix @@ -19,7 +19,12 @@ in "aerc/accounts.conf".text = lib.generators.toINI { } (lib.mapAttrs # incomplete support for all configuration options! (name: accountConfig: with accountConfig; let - quoteMailAddress = lib.replaceChars [ "@" ] [ "%40" ]; + quoteMailAddress = lib.replaceChars [ "@" "\\" ] [ "%40" "%5C" ]; + # home-manager has no way to set if an account requires AUTH LOGIN + # this emulats this by setting a list of known providers that do require it + requiresLogin = lib.elem + (lib.elemAt (lib.strings.splitString "@" address) 1) + [ "mailbox.tu-dresden.de" ]; in { source = @@ -31,7 +36,7 @@ in outgoing = if notmuch.enable then "${./msmtp-wrapper} ${name}" - else "`smtp+plain://${quoteMailAddress userName}@${smtp.host}`"; + else "`smtp${lib.optionalString requiresLogin "+login"}://${quoteMailAddress userName}@${smtp.host}`"; outgoing-cred-cmd = "`${lib.concatStringsSep " " passwordCommand}`"; from = "${realName} <${address}>"; smtp-starttls = if smtp.tls.useStartTls then "yes" else "no";