From faca09620bb208561ea9e1fc0abed0ce3f7a081b Mon Sep 17 00:00:00 2001
From: Alex ORLUC <alex.orluc@maarch.org>
Date: Fri, 26 Apr 2019 18:03:08 +0200
Subject: [PATCH] FIX #9804 TIME 0:30 normalize from mail

---
 src/app/email/controllers/EmailController.php | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/app/email/controllers/EmailController.php b/src/app/email/controllers/EmailController.php
index 6beb8cbd76a..f261d078e15 100644
--- a/src/app/email/controllers/EmailController.php
+++ b/src/app/email/controllers/EmailController.php
@@ -36,6 +36,7 @@ use Slim\Http\Request;
 use Slim\Http\Response;
 use SrcCore\models\CoreConfigModel;
 use SrcCore\models\PasswordModel;
+use SrcCore\models\TextFormatModel;
 use SrcCore\models\ValidatorModel;
 use User\models\UserModel;
 
@@ -263,10 +264,14 @@ class EmailController
 
             $emailFrom = empty($configuration['from']) ? $email['sender']['email'] : $configuration['from'];
             if (empty($email['sender']['entityId'])) {
-                $phpmailer->setFrom($emailFrom, "{$user['firstname']} {$user['lastname']}");
+                // Usefull for old sendmail server which doesn't support accent encoding
+                $setFrom = TextFormatModel::normalize(['string' => "{$user['firstname']} {$user['lastname']}"]);
+                $phpmailer->setFrom($emailFrom, ucwords($setFrom));
             } else {
                 $entity = EntityModel::getById(['id' => $email['sender']['entityId'], 'select' => ['short_label']]);
-                $phpmailer->setFrom($emailFrom, $entity['short_label']);
+                // Usefull for old sendmail server which doesn't support accent encoding
+                $setFrom = TextFormatModel::normalize(['string' => $entity['short_label']]);
+                $phpmailer->setFrom($emailFrom, ucwords($setFrom));
             }
         } elseif ($configuration['type'] == 'sendmail') {
             $phpmailer->isSendmail();
-- 
GitLab