From ea9c7a64b2d36dfa99c3b2c17135f3e9f6fe8503 Mon Sep 17 00:00:00 2001
From: Jos van den Oever <software@nlnet.nl>
Date: Wed, 20 Sep 2023 16:08:06 +0200
Subject: [PATCH] Add option sendFromAliases

---
 default.nix             | 9 +++++++++
 mail-server/postfix.nix | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/default.nix b/default.nix
index 45875a3..e76575d 100644
--- a/default.nix
+++ b/default.nix
@@ -487,6 +487,15 @@ in
       default = {};
     };
 
+    sendFromAliases = mkOption {
+      type = types.bool;
+      default = false;
+      description = ''
+        Specifies if members of an alias can send mail with the alias in the
+        From: header.
+      '';
+    };
+
     forwards = mkOption {
       type = with types; attrsOf (either (listOf str) str);
       example = {
diff --git a/mail-server/postfix.nix b/mail-server/postfix.nix
index 5a93dc2..505fd05 100644
--- a/mail-server/postfix.nix
+++ b/mail-server/postfix.nix
@@ -144,7 +144,7 @@ let
       smtpd_sasl_security_options = "noanonymous";
       smtpd_sasl_local_domain = "$myhostname";
       smtpd_client_restrictions = "permit_sasl_authenticated,reject";
-      smtpd_sender_login_maps = "hash:/etc/postfix/vaccounts${lib.optionalString cfg.ldap.enable ",ldap:${ldapSenderLoginMapFile}"}${lib.optionalString (regex_valiases_postfix != {}) ",pcre:/etc/postfix/regex_vaccounts"}";
+      smtpd_sender_login_maps = "hash:/etc/postfix/vaccounts${lib.optionalString cfg.ldap.enable ",ldap:${ldapSenderLoginMapFile}"}${lib.optionalString cfg.sendFromAliases ",$virtual_alias_maps"}${lib.optionalString (regex_valiases_postfix != {}) ",pcre:/etc/postfix/regex_vaccounts"}";
       smtpd_sender_restrictions = "reject_sender_login_mismatch";
       smtpd_recipient_restrictions = "reject_non_fqdn_recipient,reject_unknown_recipient_domain,permit_sasl_authenticated,reject";
       cleanup_service_name = "submission-header-cleanup";