From 36fd1608afb0eb84372df5ce300b0f4aa801e94c Mon Sep 17 00:00:00 2001
From: pyg77 <pyg@framasoft.net>
Date: Mon, 25 Mar 2013 16:58:49 +0100
Subject: [PATCH] =?UTF-8?q?les=20mails=20de=20cr=C3=A9ation=20de=20sondage?=
 =?UTF-8?q?s=20sont=20maintenant=20envoy=C3=A9s=20avec=20un=20reply-to=20c?=
 =?UTF-8?q?onfigur=C3=A9=20sur=20l'adresse=20du=20cr=C3=A9ateur=20du=20son?=
 =?UTF-8?q?dage=20et=20un=20from=20qui=20n'est=20pas=20obligatoirement=20l?=
 =?UTF-8?q?'adresse=20de=20l'admin=20de=20l'application?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 creation_sondage.php |  4 ++--
 fonctions.php        | 10 ++++++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/creation_sondage.php b/creation_sondage.php
index f0e2d409..3e342941 100644
--- a/creation_sondage.php
+++ b/creation_sondage.php
@@ -116,8 +116,8 @@ function ajouter_sondage()
   $message_admin = sprintf($message_admin, getUrlSondage($sondage_admin, true));
   
   if (validateEmail($_SESSION['adresse'])) {
-    sendEmail( "$_SESSION[adresse]", "[".NOMAPPLICATION."][" . _("Author's message")  . "] " . _("Poll") . " : ".stripslashes(htmlspecialchars_decode($_SESSION["titre"],ENT_QUOTES)), $message_admin );
-    sendEmail( "$_SESSION[adresse]", "[".NOMAPPLICATION."][" . _("For sending to the polled users") . "] " . _("Poll") . " : ".stripslashes(htmlspecialchars_decode($_SESSION["titre"],ENT_QUOTES)), $message );
+    sendEmail( "$_SESSION[adresse]", "[".NOMAPPLICATION."][" . _("Author's message")  . "] " . _("Poll") . " : ".stripslashes(htmlspecialchars_decode($_SESSION["titre"],ENT_QUOTES)), $message_admin, $_SESSION['adresse'] );
+    sendEmail( "$_SESSION[adresse]", "[".NOMAPPLICATION."][" . _("For sending to the polled users") . "] " . _("Poll") . " : ".stripslashes(htmlspecialchars_decode($_SESSION["titre"],ENT_QUOTES)), $message, $_SESSION['adresse'] );
   }
   
   $date=date('H:i:s d/m/Y:');
diff --git a/fonctions.php b/fonctions.php
index 5f84fe8a..92837d3c 100644
--- a/fonctions.php
+++ b/fonctions.php
@@ -168,10 +168,20 @@ function sendEmail( $to, $subject, $body, $headers, $param)
   } else {
     $folding = "" ;
   } ;
+  // si $headers ne contient qu'une adresse email, on la considère comme adresse de reply-to, sinon on met l'adresse de no-reply definie dans variables.php
+  if (validateEmail($headers)) {
+    $replyTo = $headers;
+    $headers = ""; // on reinitialise $headers
+  } else {
+    $replyTo = ADRESSEEMAILREPONSEAUTO;
+  }
+  
+  
   $from = sprintf( "From: %s%s <%s>\n", $encoded_app, $folding, ADRESSEMAILADMIN ) ;
 
   if ( $headers ) $headers .= "\n" ;
   $headers .= $from ;
+  $headers .= "Reply-To: $replyTo\n";
   $headers .= "MIME-Version: 1.0\n" ;
   $headers .= "Content-Type: text/plain; charset=UTF-8\n" ;
   $headers .= "Content-Transfer-Encoding: 8bit" ;
-- 
GitLab