From a17608509a5f891ceb3ebf0a70672a9ad2707092 Mon Sep 17 00:00:00 2001 From: niten Date: Fri, 13 Oct 2023 17:42:43 -0700 Subject: [PATCH] Add sender/login maps for aliases --- postfix.nix | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/postfix.nix b/postfix.nix index 1b4eaf5..e7cee9a 100644 --- a/postfix.nix +++ b/postfix.nix @@ -319,8 +319,17 @@ in { (mkRejectList cfg.blacklist.recipients); virtual_mailbox_map = writeEntries "virtual_mailbox_map" (map (domain: "@${domain} OK") allDomains); - sender_login_map = writeEntries "sender_login_maps" - (map (domain: "/^(.*)@${escapeDot domain}$/ \${1}") allDomains); + sender_login_map = let + defaultMaps = + map (domain: "/^(.*)@${escapeDot domain}$/ \${1}") allDomains; + userAliasMaps = concatMapAttrsToList (username: userAliases: + map (alias: "/^${escapeDot alias}$/ ${username}")) + cfg.aliases.user-aliases; + aliasUserMaps = mapAttrsToList (alias: users: + "/^${escapeDot alias}$/ ${concatStringsSep "," users}") + cfg.aliases.alias-users; + in writeEntries "sender_login_maps" + (defaultMaps ++ userAliasMaps ++ aliasUserMaps); }; networks = cfg.trusted-networks;