From 80167cfb42ac235d87e2ef483a129ed8c826ee47 Mon Sep 17 00:00:00 2001
From: Thibault Dockx <thibault.dockx@fusiondirectory.org>
Date: Mon, 25 Nov 2024 21:52:21 +0000
Subject: [PATCH] :sparkles: (CORE) - Mail - supannMailPrivee is taken
 correctly

Email format from supann mail privee is now ok.
---
 plugins/workflow/tasks/class_tasksMail.inc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/plugins/workflow/tasks/class_tasksMail.inc b/plugins/workflow/tasks/class_tasksMail.inc
index 8eeba2451..e8cf6a684 100644
--- a/plugins/workflow/tasks/class_tasksMail.inc
+++ b/plugins/workflow/tasks/class_tasksMail.inc
@@ -189,8 +189,12 @@ class tasksMail extends simplePlugin
       $info = $ldap->fetch();
 
       if (!empty($info[$mailAttr][0])) {
-        // In case of private supann mail, remove the prefix
-        $mailList[] = preg_replace('/.+?(?=supann)/', '', $info[$mailAttr][0]);
+
+        // Remove anything between curly braces (e.g., {PERSO}, {PRO} as well as supann labels)
+        $cleanMail = preg_replace('/.+?(?=supann)/', '', $info[$mailAttr][0]);
+        $finalMail = preg_replace('/\{.*?\}/', '', $cleanMail);
+
+        $mailList[] = $finalMail;
 
         // Render the mailing list unique, somewhat mandatory when updating the members lists with dynGroups and members.
         $mailList = array_unique($mailList);
-- 
GitLab