From 546385a12804908791f9dd4f2808d57e6836286f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Gu=C3=A9rard?= Date: Wed, 18 Jan 2012 00:24:16 +0100 Subject: [PATCH] Header encoding done with std functions --- fonctions.php | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/fonctions.php b/fonctions.php index 521ef69..b5b4819 100644 --- a/fonctions.php +++ b/fonctions.php @@ -163,33 +163,24 @@ function validateEmail($email) # Envoi un courrier avec un codage correct de To et Subject # Les en-têtes complémentaires ne sont pas gérés -# Inspiré de http://geoland.org/2007/12/utf8-ready-php-mail-function/ function sendEmail( $to, $subject, $body, $headers, $param) { - $to_list = explode( ',', html_entity_decode( $to, ENT_QUOTES, 'UTF-8' ) ) ; - $to = "" ; - $first = 1 ; - foreach ( $to_list as $one ) { - if ( $first == 0 ) $to .= ',' ; - if ( preg_match( "/ 74 ) $folding = "\n" + else $folding = "" ; + $from = sprintf( "From: %s%s <%s>\n", $encoded_app, $folding, ADRESSEMAILADMIN ) ; - if ( $headers ) $headers .= "\r\n" ; - $headers .= sprintf( "From: %s <%s>\r\n", $encoded_app, ADRESSEMAILADMIN ) ; - $headers .= "MIME-Version: 1.0\r\n" ; - $headers .= "Content-Type: text/plain; charset=UTF-8\r\n" ; + if ( $headers ) $headers .= "\n" ; + $headers .= $from ; + $headers .= "MIME-Version: 1.0\n" ; + $headers .= "Content-Type: text/plain; charset=UTF-8\n" ; $headers .= "Content-Transfer-Encoding: 8bit" ; $body = html_entity_decode( $body, ENT_QUOTES, 'UTF-8' ) ;