From 3d571ae2337a6a3e3f5aa377d1ddc1d201dda0a7 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Tue, 13 Jun 2017 14:16:58 +0000 Subject: [PATCH] mail: add a Return-Path header is done on the first line and the other headers are added at the end of the headers git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3759 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- mail.php | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/mail.php b/mail.php index 151fb36..52a0bad 100644 --- a/mail.php +++ b/mail.php @@ -1119,9 +1119,31 @@ class mail throw new \Exception ("Wanted section not found in addHeader", 404); $sectionMainID = $sectionID; } - $this->sections[$sectionMainID]["_headersArray"][][$header] = $value; - // TODO : Encode ? Strip ? - $this->sections[$sectionMainID]["_headersEML"] .= "$header: $value"; + if ($header === "Return-Path") + { + // Must be placed on the first line and must be unique + reset ($this->sections[$sectionMainID]["_headersArray"]); + if (key_exists (0, $this->sections[$sectionMainID]["_headersArray"]) && + key_exists ("Return-Path", $this->sections[$sectionMainID]["_headersArray"][0])) + { + // Remove the old one + array_shift ($this->sections[$sectionMainID]["_headersArray"]); + $this->sections[$sectionMainID]["_headersEML"] = + substr ($this->sections[$sectionMainID]["_headersEML"], + strpos ($this->sections[$sectionMainID]["_headersEML"], "\n") +1); + } + array_unshift ($this->sections[$sectionMainID]["_headersArray"], + array ($header => $value)); + $this->sections[$sectionMainID]["_headersEML"] = "$header: $value". + $this->sections[$sectionMainID]["_headersEML"]; + } + else + { + // The "normal" headers are places sequentially at the end of the headers + $this->sections[$sectionMainID]["_headersArray"][][$header] = $value; + // TODO : Encode ? Strip ? + $this->sections[$sectionMainID]["_headersEML"] .= "$header: $value"; + } $this->createMailEML (); }