From 848dcc53702f3b73f9169bc3457d4b3907fbedbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Gu=C3=A9rard?= Date: Mon, 9 Jan 2012 01:26:44 +0100 Subject: [PATCH 01/15] Fix encoding for To and Subject headers --- adminstuds.php | 26 +++++++++++++------------- contacts.php | 6 +++--- creation_sondage.php | 6 +++--- fonctions.php | 25 ++++++++++++++++++++++++- studs.php | 6 +++--- 5 files changed, 46 insertions(+), 23 deletions(-) diff --git a/adminstuds.php b/adminstuds.php index a111504..a1e98ad 100644 --- a/adminstuds.php +++ b/adminstuds.php @@ -122,12 +122,12 @@ if (isset($_POST["boutonnouveautitre"]) || isset($_POST["boutonnouveautitre_x"]) //envoi du mail pour prevenir l'admin de sondage if ($connect->Execute($sql, array($nouveautitre, $numsondage))) { - mail ($adresseadmin, + sendEmail( $adresseadmin, _("[ADMINISTRATOR] New title for your poll") . ' ' . NOMAPPLICATION, _("You have changed the title of your poll. \nYou can modify this poll with this link") . " :\n\n".getUrlSondage($numsondageadmin, true)."\n\n" . _("Thanks for your confidence.") . "\n" . NOMAPPLICATION, - $headers); + $headers ); } } } @@ -145,12 +145,12 @@ if (isset($_POST["boutonnouveauxcommentaires"]) || isset($_POST["boutonnouveauxc if ($connect->Execute($sql, array($commentaires, $numsondage))) { //envoi du mail pour prevenir l'admin de sondage - mail ($adresseadmin, + sendEmail( $adresseadmin, _("[ADMINISTRATOR] New comments for your poll") . ' ' . NOMAPPLICATION, _("You have changed the comments of your poll. \nYou can modify this poll with this link") . " :\n\n".getUrlSondage($numsondageadmin, true)." \n\n" . _("Thanks for your confidence.") . "\n" . NOMAPPLICATION, - $headers); + $headers ); } } } @@ -168,12 +168,12 @@ if (isset($_POST["boutonnouvelleadresse"]) || isset($_POST["boutonnouvelleadress if ($connect->Execute($sql, array($nouvelleadresse, $numsondage))) { //envoi du mail pour prevenir l'admin de sondage - mail ($_POST['nouvelleadresse'], + sendEmail( $_POST['nouvelleadresse'], _("[ADMINISTRATOR] New email address for your poll") . ' ' . NOMAPPLICATION, _("You have changed your email address in your poll. \nYou can modify this poll with this link") . " :\n\n".getUrlSondage($numsondageadmin, true)."\n\n" . _("Thanks for your confidence.") . "\n" . NOMAPPLICATION, - $headers); + $headers ); } } } @@ -329,12 +329,12 @@ if (isset($_POST["confirmesuppression"]) || isset($_POST["confirmesuppression_x" error_log($date . " SUPPRESSION: $dsondage->id_sondage\t$dsondage->format\t$dsondage->nom_admin\t$dsondage->mail_admin\n", 3, 'admin/logs_studs.txt'); //envoi du mail a l'administrateur du sondage - mail ($adresseadmin, + sendEmail( $adresseadmin, _("[ADMINISTRATOR] Removing of your poll") . ' ' . NOMAPPLICATION, _("You have removed your poll. \nYou can make new polls with this link") . " :\n\n".get_server_name()."index.php \n\n" . _("Thanks for your confidence.") . "\n" . NOMAPPLICATION, - $headers); + $headers ); //affichage de l'ecran de confirmation de suppression de sondage print_header(); @@ -478,10 +478,10 @@ if (isset($_POST["ajoutercolonne_x"]) && issetAndNoEmpty('nouvellecolonne') && ( if ($connect->Execute($sql, array($nouveauxsujets, $numsondage))) { //envoi d'un mail pour prévenir l'administrateur du changement $headers="From: ".NOMAPPLICATION." <".ADRESSEMAILADMIN.">\r\nContent-Type: text/plain; charset=\"UTF-8\"\nContent-Transfer-Encoding: 8bit"; - mail ("$adresseadmin", "" . _("[ADMINISTRATOR] New column for your poll").NOMAPPLICATION, "" . + sendEmail( "$adresseadmin", "" . _("[ADMINISTRATOR] New column for your poll").NOMAPPLICATION, "" . _("You have added a new column in your poll. \nYou can inform the voters of this change with this link") . " : \n\n".getUrlSondage($numsondage)." \n\n " . _("Thanks for your confidence.") . "\n".NOMAPPLICATION, - $headers); + $headers ); } } @@ -592,11 +592,11 @@ if (isset($_POST["ajoutercolonne_x"]) && ($dsondage->format == "D" || $dsondage- //envoi d'un mail pour prévenir l'administrateur du changement $adresseadmin = $dsondage->mail_admin; - mail ($adresseadmin, + sendEmail( $adresseadmin, _("[ADMINISTRATOR] New column for your poll"), _("You have added a new column in your poll. \nYou can inform the voters of this change with this link"). " : \n\n".getUrlSondage($numsondage)." \n\n " . _("Thanks for your confidence.") . "\n".NOMAPPLICATION, - $headers); + $headers ); } else { $erreur_ajout_date="yes"; } @@ -1257,4 +1257,4 @@ echo '
 
'; bandeau_pied_mobile(); echo ''."\n"; echo ''."\n"; -echo ''."\n"; \ No newline at end of file +echo ''."\n"; diff --git a/contacts.php b/contacts.php index 0e4b306..3ca5f48 100644 --- a/contacts.php +++ b/contacts.php @@ -56,10 +56,10 @@ if ((isset($_POST['envoiquestion']) || isset($_POST['envoiquestion_x'])) && isse if (isset($_POST['adresse_mail']) && !empty($_POST['adresse_mail']) && validateEmail($_POST['adresse_mail'])) { $headers .= "\r\n".'Reply-To: '.$_POST['adresse_mail']; } - mail (ADRESSEMAILADMIN, "" . _("[CONTACT] You have sent a question ") . "".NOMAPPLICATION, "" . _("You have a question from a user ") . " ".NOMAPPLICATION."\n\n" . _("User") . " : ".$_POST["nom"]."\n\n" . _("User's email address") . " : $_POST[adresse_mail]\n\n" . _("Message") . " :".$message,$headers); + sendEmail( ADRESSEMAILADMIN, "" . _("[CONTACT] You have sent a question ") . "".NOMAPPLICATION, "" . _("You have a question from a user ") . " ".NOMAPPLICATION."\n\n" . _("User") . " : ".$_POST["nom"]."\n\n" . _("User's email address") . " : $_POST[adresse_mail]\n\n" . _("Message") . " :".$message,$headers ); if (isset($_POST['adresse_mail']) && !empty($_POST['adresse_mail']) && validateEmail($_POST['adresse_mail'])) { $headers="From: ".NOMAPPLICATION." <".ADRESSEMAILADMIN.">\r\nContent-Type: text/plain; charset=\"UTF-8\"\nContent-Transfer-Encoding: 8bit"; - mail ("$_POST[adresse_mail]", "" . _("[COPY] Someone has sent a question ") . "".NOMAPPLICATION, "" . _("Here is a copy of your question") . " :\n\n".$message." \n\n" . _("We're going to answer your question shortly.") . "\n\n" . _("Thanks for your confidence.") . "\n".NOMAPPLICATION,$headers); + sendEmail( "$_POST[adresse_mail]", "" . _("[COPY] Someone has sent a question ") . "".NOMAPPLICATION, "" . _("Here is a copy of your question") . " :\n\n".$message." \n\n" . _("We're going to answer your question shortly.") . "\n\n" . _("Thanks for your confidence.") . "\n".NOMAPPLICATION,$headers ); } //affichage de la page de confirmation d'envoi @@ -148,4 +148,4 @@ framanav(); bandeau_pied(); echo ''."\n"; echo ''."\n"; -} \ No newline at end of file +} diff --git a/creation_sondage.php b/creation_sondage.php index 641ffae..38ae7fe 100644 --- a/creation_sondage.php +++ b/creation_sondage.php @@ -118,8 +118,8 @@ function ajouter_sondage() $message_admin = sprintf($message_admin, getUrlSondage($sondage_admin, true)); if (validateEmail($_SESSION['adresse'])) { - mail ("$_SESSION[adresse]", "[".NOMAPPLICATION."][" . _("Author's message") . "] " . _("Poll") . " : ".stripslashes(htmlspecialchars_decode($_SESSION["titre"],ENT_QUOTES)), $message_admin, $headers); - mail ("$_SESSION[adresse]", "[".NOMAPPLICATION."][" . _("For sending to the polled users") . "] " . _("Poll") . " : ".stripslashes(htmlspecialchars_decode($_SESSION["titre"],ENT_QUOTES)), $message, $headers); + sendEmail( "$_SESSION[adresse]", "[".NOMAPPLICATION."][" . _("Author's message") . "] " . _("Poll") . " : ".stripslashes(htmlspecialchars_decode($_SESSION["titre"],ENT_QUOTES)), $message_admin, $headers ); + sendEmail( "$_SESSION[adresse]", "[".NOMAPPLICATION."][" . _("For sending to the polled users") . "] " . _("Poll") . " : ".stripslashes(htmlspecialchars_decode($_SESSION["titre"],ENT_QUOTES)), $message, $headers ); } $date=date('H:i:s d/m/Y:'); @@ -127,4 +127,4 @@ function ajouter_sondage() header("Location:".getUrlSondage($sondage)); exit(); session_unset(); -} \ No newline at end of file +} diff --git a/fonctions.php b/fonctions.php index adc128b..c4f3ada 100644 --- a/fonctions.php +++ b/fonctions.php @@ -161,6 +161,29 @@ function validateEmail($email) return (bool)preg_match($pattern, $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( ',', $to ) ; + $to = "" ; + $first = 1 ; + + foreach ( $to_list as $one ) { + if ( $first == 0 ) $to .= ',' ; + $to_cut = explode( '<' ,$one, 2 ) ; + $to .= '=?UTF-8?B?' . base64_encode( $to_cut[ 0 ] ) . '?= <' . $to_cut[ 1 ] ; + $first = 0 ; + } ; + + $subject = '=?UTF-8?B?' . base64_encode( $subject ) . '?=' ; + + mail( $to, $subject, $body, $headers, $param ) ; + +} + /** * Fonction vérifiant l'existance et la valeur non vide d'une clé d'un tableau @@ -216,4 +239,4 @@ define('NO_POLL_ID', 0x0001000000); define('INVALID_EMAIL', 0x0010000000); define('TITLE_EMPTY', 0x0100000000); define('INVALID_DATE', 0x1000000000); -$err = 0; \ No newline at end of file +$err = 0; diff --git a/studs.php b/studs.php index f113838..f8446e0 100644 --- a/studs.php +++ b/studs.php @@ -172,13 +172,13 @@ if (!is_error(NO_POLL) && (isset($_POST["boutonp"]) || isset($_POST["boutonp_x"] if ($dsondage->mailsonde || /* compatibility for non boolean DB */ $dsondage->mailsonde=="yes" || $dsondage->mailsonde=="true") { $headers="From: ".NOMAPPLICATION." <".ADRESSEMAILADMIN.">\r\nContent-Type: text/plain; charset=\"UTF-8\"\nContent-Transfer-Encoding: 8bit"; - mail ("$dsondage->mail_admin", + sendEmail( "$dsondage->mail_admin", "[".NOMAPPLICATION."] "._("Poll's participation")." : ".html_entity_decode($dsondage->titre, ENT_QUOTES, 'UTF-8')."", html_entity_decode("\"$nom\" ", ENT_QUOTES, 'UTF-8'). _("has filled a line.\nYou can find your poll at the link") . " :\n\n". getUrlSondage($numsondage)." \n\n" . _("Thanks for your confidence.") . "\n". NOMAPPLICATION, - $headers); + $headers ); } } } else { @@ -308,7 +308,7 @@ if ($testmodifier) { if ($dsondage->mailsonde=="yes") { $headers="From: ".NOMAPPLICATION." <".ADRESSEMAILADMIN.">\r\nContent-Type: text/plain; charset=\"UTF-8\"\nContent-Transfer-Encoding: 8bit"; - mail ("$dsondage->mail_admin", "[".NOMAPPLICATION."] " . _("Poll's participation") . " : ".html_entity_decode($dsondage->titre, ENT_QUOTES, 'UTF-8'), "\"".html_entity_decode($data->nom, ENT_QUOTES, 'UTF-8')."\""."" . _("has filled a line.\nYou can find your poll at the link") . " :\n\n".getUrlSondage($numsondage)." \n\n" . _("Thanks for your confidence.") . "\n".NOMAPPLICATION,$headers); + sendEmail( "$dsondage->mail_admin", "[".NOMAPPLICATION."] " . _("Poll's participation") . " : ".html_entity_decode($dsondage->titre, ENT_QUOTES, 'UTF-8'), "\"".html_entity_decode($data->nom, ENT_QUOTES, 'UTF-8')."\""."" . _("has filled a line.\nYou can find your poll at the link") . " :\n\n".getUrlSondage($numsondage)." \n\n" . _("Thanks for your confidence.") . "\n".NOMAPPLICATION,$headers ); } } From 1059a4108a91875ec13d0966e4b7ecd4a60a9fd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Gu=C3=A9rard?= Date: Mon, 9 Jan 2012 01:55:07 +0100 Subject: [PATCH 02/15] Make it work if To is only an address --- fonctions.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fonctions.php b/fonctions.php index c4f3ada..c601097 100644 --- a/fonctions.php +++ b/fonctions.php @@ -173,8 +173,12 @@ function sendEmail( $to, $subject, $body, $headers, $param) foreach ( $to_list as $one ) { if ( $first == 0 ) $to .= ',' ; - $to_cut = explode( '<' ,$one, 2 ) ; - $to .= '=?UTF-8?B?' . base64_encode( $to_cut[ 0 ] ) . '?= <' . $to_cut[ 1 ] ; + if ( preg_match( "/ Date: Mon, 9 Jan 2012 02:18:25 +0100 Subject: [PATCH 03/15] Fix encoding of the From header --- adminstuds.php | 11 +++-------- contacts.php | 5 +++-- creation_sondage.php | 2 +- fonctions.php | 16 ++++++++++++++++ studs.php | 4 ++-- 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/adminstuds.php b/adminstuds.php index a1e98ad..45c7c0b 100644 --- a/adminstuds.php +++ b/adminstuds.php @@ -103,13 +103,7 @@ $dsondage=$sondage->FetchObject(false); //si la valeur du nouveau titre est valide et que le bouton est activé $adresseadmin = $dsondage->mail_admin; -$headers_str = << -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit -EOF; -$headers = sprintf($headers_str, NOMAPPLICATION, ADRESSEMAILADMIN); - +$headers = makeHeaders() ; if (isset($_POST["boutonnouveautitre"]) || isset($_POST["boutonnouveautitre_x"])) { if(issetAndNoEmpty('nouveautitre') === false) { @@ -477,7 +471,8 @@ if (isset($_POST["ajoutercolonne_x"]) && issetAndNoEmpty('nouvellecolonne') && ( $sql = $connect->Prepare($sql); if ($connect->Execute($sql, array($nouveauxsujets, $numsondage))) { //envoi d'un mail pour prévenir l'administrateur du changement - $headers="From: ".NOMAPPLICATION." <".ADRESSEMAILADMIN.">\r\nContent-Type: text/plain; charset=\"UTF-8\"\nContent-Transfer-Encoding: 8bit"; + $headers = makeHeaders() ; + sendEmail( "$adresseadmin", "" . _("[ADMINISTRATOR] New column for your poll").NOMAPPLICATION, "" . _("You have added a new column in your poll. \nYou can inform the voters of this change with this link") . " : \n\n".getUrlSondage($numsondage)." \n\n " . _("Thanks for your confidence.") . "\n".NOMAPPLICATION, diff --git a/contacts.php b/contacts.php index 3ca5f48..ef6c9a3 100644 --- a/contacts.php +++ b/contacts.php @@ -52,13 +52,14 @@ if ((isset($_POST['envoiquestion']) || isset($_POST['envoiquestion_x'])) && isse $message=str_replace("\\","",$_POST["question"]); //envoi des mails - $headers="From: ".NOMAPPLICATION." <".ADRESSEMAILADMIN.">\r\nContent-Type: text/plain; charset=\"UTF-8\"\r\nContent-Transfer-Encoding: 8bit"; + $headers = makeHeaders() ; + if (isset($_POST['adresse_mail']) && !empty($_POST['adresse_mail']) && validateEmail($_POST['adresse_mail'])) { $headers .= "\r\n".'Reply-To: '.$_POST['adresse_mail']; } sendEmail( ADRESSEMAILADMIN, "" . _("[CONTACT] You have sent a question ") . "".NOMAPPLICATION, "" . _("You have a question from a user ") . " ".NOMAPPLICATION."\n\n" . _("User") . " : ".$_POST["nom"]."\n\n" . _("User's email address") . " : $_POST[adresse_mail]\n\n" . _("Message") . " :".$message,$headers ); if (isset($_POST['adresse_mail']) && !empty($_POST['adresse_mail']) && validateEmail($_POST['adresse_mail'])) { - $headers="From: ".NOMAPPLICATION." <".ADRESSEMAILADMIN.">\r\nContent-Type: text/plain; charset=\"UTF-8\"\nContent-Transfer-Encoding: 8bit"; + $headers = makeHeaders() ; sendEmail( "$_POST[adresse_mail]", "" . _("[COPY] Someone has sent a question ") . "".NOMAPPLICATION, "" . _("Here is a copy of your question") . " :\n\n".$message." \n\n" . _("We're going to answer your question shortly.") . "\n\n" . _("Thanks for your confidence.") . "\n".NOMAPPLICATION,$headers ); } diff --git a/creation_sondage.php b/creation_sondage.php index 38ae7fe..beb8487 100644 --- a/creation_sondage.php +++ b/creation_sondage.php @@ -82,7 +82,7 @@ function ajouter_sondage() $date_fin = time()+15552000; } - $headers="From: ".NOMAPPLICATION." <".ADRESSEMAILADMIN.">\r\nContent-Type: text/plain; charset=\"UTF-8\"\nContent-Transfer-Encoding: 8bit"; + $headers = makeHeaders() ; global $connect; diff --git a/fonctions.php b/fonctions.php index c601097..1e720fa 100644 --- a/fonctions.php +++ b/fonctions.php @@ -188,6 +188,22 @@ function sendEmail( $to, $subject, $body, $headers, $param) } +function makeHeaders() { + + $headers_str = << +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +EOF; + + $encoded_app = '=?UTF-8?B?' . base64_encode( NOMAPPLICATION, ) . '?=' ; + $headers = sprintf( $headers_str, $encoded_app, ADRESSEMAILADMIN ) ; + + return $headers ; + +} + /** * Fonction vérifiant l'existance et la valeur non vide d'une clé d'un tableau diff --git a/studs.php b/studs.php index f8446e0..c74052b 100644 --- a/studs.php +++ b/studs.php @@ -171,7 +171,7 @@ if (!is_error(NO_POLL) && (isset($_POST["boutonp"]) || isset($_POST["boutonp_x"] $connect->Execute($sql, array($nom, $numsondage, $nouveauchoix)); if ($dsondage->mailsonde || /* compatibility for non boolean DB */ $dsondage->mailsonde=="yes" || $dsondage->mailsonde=="true") { - $headers="From: ".NOMAPPLICATION." <".ADRESSEMAILADMIN.">\r\nContent-Type: text/plain; charset=\"UTF-8\"\nContent-Transfer-Encoding: 8bit"; + $headers = makeHeaders() ; sendEmail( "$dsondage->mail_admin", "[".NOMAPPLICATION."] "._("Poll's participation")." : ".html_entity_decode($dsondage->titre, ENT_QUOTES, 'UTF-8')."", html_entity_decode("\"$nom\" ", ENT_QUOTES, 'UTF-8'). @@ -307,7 +307,7 @@ if ($testmodifier) { $connect->Execute($sql, array($nouveauchoix, $data->nom, $data->id_users)); if ($dsondage->mailsonde=="yes") { - $headers="From: ".NOMAPPLICATION." <".ADRESSEMAILADMIN.">\r\nContent-Type: text/plain; charset=\"UTF-8\"\nContent-Transfer-Encoding: 8bit"; + $headers = makeHeaders() ; sendEmail( "$dsondage->mail_admin", "[".NOMAPPLICATION."] " . _("Poll's participation") . " : ".html_entity_decode($dsondage->titre, ENT_QUOTES, 'UTF-8'), "\"".html_entity_decode($data->nom, ENT_QUOTES, 'UTF-8')."\""."" . _("has filled a line.\nYou can find your poll at the link") . " :\n\n".getUrlSondage($numsondage)." \n\n" . _("Thanks for your confidence.") . "\n".NOMAPPLICATION,$headers ); } } From bd13da4b58f36e007423f7e36d7dd18620188c5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Gu=C3=A9rard?= Date: Mon, 9 Jan 2012 02:23:28 +0100 Subject: [PATCH 04/15] Syntax error --- fonctions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fonctions.php b/fonctions.php index 1e720fa..e1b05b4 100644 --- a/fonctions.php +++ b/fonctions.php @@ -197,7 +197,7 @@ Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit EOF; - $encoded_app = '=?UTF-8?B?' . base64_encode( NOMAPPLICATION, ) . '?=' ; + $encoded_app = '=?UTF-8?B?' . base64_encode( NOMAPPLICATION ) . '?=' ; $headers = sprintf( $headers_str, $encoded_app, ADRESSEMAILADMIN ) ; return $headers ; From 9722388195d27a1efb34a4c94ccd5b5d5a1d0fa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Gu=C3=A9rard?= Date: Mon, 9 Jan 2012 02:37:39 +0100 Subject: [PATCH 05/15] Fix names with accents in the user mail --- creation_sondage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/creation_sondage.php b/creation_sondage.php index beb8487..648be34 100644 --- a/creation_sondage.php +++ b/creation_sondage.php @@ -108,7 +108,7 @@ function ajouter_sondage() $message = _("This is the message you have to send to the people you want to poll. \nNow, you have to send this message to everyone you want to poll."); $message .= "\n\n"; - $message .= stripslashes(htmlspecialchars_decode($_SESSION["nom"],ENT_QUOTES))." " . _("hast just created a poll called") . " : \"".stripslashes(htmlspecialchars_decode($_SESSION["titre"],ENT_QUOTES))."\".\n"; + $message .= stripslashes(html_entity_decode($_SESSION["nom"],ENT_QUOTES,"UTF-8"))." " . _("hast just created a poll called") . " : \"".stripslashes(htmlspecialchars_decode($_SESSION["titre"],ENT_QUOTES))."\".\n"; $message .= _("Thanks for filling the poll at the link above") . " :\n\n%s\n\n" . _("Thanks for your confidence") . ",\n".NOMAPPLICATION; $message_admin = _("This message should NOT be sended to the polled people. It is private for the poll's creator.\n\nYou can now modify it at the link above"); From 09d89d117ba24a58516649350764793be38b4b52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Gu=C3=A9rard?= Date: Tue, 10 Jan 2012 00:27:09 +0100 Subject: [PATCH 06/15] =?UTF-8?q?Always=20decode=20HTML=C2=A0entities?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fonctions.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fonctions.php b/fonctions.php index e1b05b4..b0cb69c 100644 --- a/fonctions.php +++ b/fonctions.php @@ -167,7 +167,7 @@ function validateEmail($email) function sendEmail( $to, $subject, $body, $headers, $param) { - $to_list = explode( ',', $to ) ; + $to_list = explode( ',', html_entity_decode($to, ENT_QUOTES, 'UTF-8' ) ; $to = "" ; $first = 1 ; @@ -182,7 +182,8 @@ function sendEmail( $to, $subject, $body, $headers, $param) $first = 0 ; } ; - $subject = '=?UTF-8?B?' . base64_encode( $subject ) . '?=' ; + $subject = '=?UTF-8?B?' . base64_encode( html_entity_decode( $subject, ENT_QUOTES, 'UTF-8' ) ) . '?=' ; + $body = html_entity_decode( $body, ENT_QUOTES, 'UTF-8' ) ; mail( $to, $subject, $body, $headers, $param ) ; From 139e4ba9a652c0bc71be84176bf82abf6a9070ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Gu=C3=A9rard?= Date: Tue, 10 Jan 2012 00:34:44 +0100 Subject: [PATCH 07/15] Add a missing parenthesis --- fonctions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fonctions.php b/fonctions.php index b0cb69c..169a538 100644 --- a/fonctions.php +++ b/fonctions.php @@ -167,7 +167,7 @@ function validateEmail($email) function sendEmail( $to, $subject, $body, $headers, $param) { - $to_list = explode( ',', html_entity_decode($to, ENT_QUOTES, 'UTF-8' ) ; + $to_list = explode( ',', html_entity_decode( $to, ENT_QUOTES, 'UTF-8' ) ) ; $to = "" ; $first = 1 ; From bebfc4b4e7c3c041b923a95fd063ad731011a47d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Gu=C3=A9rard?= Date: Wed, 11 Jan 2012 20:34:37 +0100 Subject: [PATCH 08/15] Headers separation fix Fix the header separating character (needs to be \r\n). Merge header creation with sendEmail. --- adminstuds.php | 20 ++++++-------------- contacts.php | 9 +++++---- creation_sondage.php | 6 ++---- fonctions.php | 25 +++++++++---------------- studs.php | 7 ++----- 5 files changed, 24 insertions(+), 43 deletions(-) diff --git a/adminstuds.php b/adminstuds.php index 45c7c0b..9ee5b9d 100644 --- a/adminstuds.php +++ b/adminstuds.php @@ -103,7 +103,6 @@ $dsondage=$sondage->FetchObject(false); //si la valeur du nouveau titre est valide et que le bouton est activé $adresseadmin = $dsondage->mail_admin; -$headers = makeHeaders() ; if (isset($_POST["boutonnouveautitre"]) || isset($_POST["boutonnouveautitre_x"])) { if(issetAndNoEmpty('nouveautitre') === false) { @@ -120,8 +119,7 @@ if (isset($_POST["boutonnouveautitre"]) || isset($_POST["boutonnouveautitre_x"]) _("[ADMINISTRATOR] New title for your poll") . ' ' . NOMAPPLICATION, _("You have changed the title of your poll. \nYou can modify this poll with this link") . " :\n\n".getUrlSondage($numsondageadmin, true)."\n\n" . - _("Thanks for your confidence.") . "\n" . NOMAPPLICATION, - $headers ); + _("Thanks for your confidence.") . "\n" . NOMAPPLICATION ); } } } @@ -143,8 +141,7 @@ if (isset($_POST["boutonnouveauxcommentaires"]) || isset($_POST["boutonnouveauxc _("[ADMINISTRATOR] New comments for your poll") . ' ' . NOMAPPLICATION, _("You have changed the comments of your poll. \nYou can modify this poll with this link") . " :\n\n".getUrlSondage($numsondageadmin, true)." \n\n" . - _("Thanks for your confidence.") . "\n" . NOMAPPLICATION, - $headers ); + _("Thanks for your confidence.") . "\n" . NOMAPPLICATION ); } } } @@ -166,8 +163,7 @@ if (isset($_POST["boutonnouvelleadresse"]) || isset($_POST["boutonnouvelleadress _("[ADMINISTRATOR] New email address for your poll") . ' ' . NOMAPPLICATION, _("You have changed your email address in your poll. \nYou can modify this poll with this link") . " :\n\n".getUrlSondage($numsondageadmin, true)."\n\n" . - _("Thanks for your confidence.") . "\n" . NOMAPPLICATION, - $headers ); + _("Thanks for your confidence.") . "\n" . NOMAPPLICATION ); } } } @@ -327,8 +323,7 @@ if (isset($_POST["confirmesuppression"]) || isset($_POST["confirmesuppression_x" _("[ADMINISTRATOR] Removing of your poll") . ' ' . NOMAPPLICATION, _("You have removed your poll. \nYou can make new polls with this link") . " :\n\n".get_server_name()."index.php \n\n" . - _("Thanks for your confidence.") . "\n" . NOMAPPLICATION, - $headers ); + _("Thanks for your confidence.") . "\n" . NOMAPPLICATION ); //affichage de l'ecran de confirmation de suppression de sondage print_header(); @@ -471,12 +466,10 @@ if (isset($_POST["ajoutercolonne_x"]) && issetAndNoEmpty('nouvellecolonne') && ( $sql = $connect->Prepare($sql); if ($connect->Execute($sql, array($nouveauxsujets, $numsondage))) { //envoi d'un mail pour prévenir l'administrateur du changement - $headers = makeHeaders() ; sendEmail( "$adresseadmin", "" . _("[ADMINISTRATOR] New column for your poll").NOMAPPLICATION, "" . _("You have added a new column in your poll. \nYou can inform the voters of this change with this link") . - " : \n\n".getUrlSondage($numsondage)." \n\n " . _("Thanks for your confidence.") . "\n".NOMAPPLICATION, - $headers ); + " : \n\n".getUrlSondage($numsondage)." \n\n " . _("Thanks for your confidence.") . "\n".NOMAPPLICATION ); } } @@ -590,8 +583,7 @@ if (isset($_POST["ajoutercolonne_x"]) && ($dsondage->format == "D" || $dsondage- sendEmail( $adresseadmin, _("[ADMINISTRATOR] New column for your poll"), _("You have added a new column in your poll. \nYou can inform the voters of this change with this link"). - " : \n\n".getUrlSondage($numsondage)." \n\n " . _("Thanks for your confidence.") . "\n".NOMAPPLICATION, - $headers ); + " : \n\n".getUrlSondage($numsondage)." \n\n " . _("Thanks for your confidence.") . "\n".NOMAPPLICATION ); } else { $erreur_ajout_date="yes"; } diff --git a/contacts.php b/contacts.php index ef6c9a3..d1d72c4 100644 --- a/contacts.php +++ b/contacts.php @@ -52,15 +52,16 @@ if ((isset($_POST['envoiquestion']) || isset($_POST['envoiquestion_x'])) && isse $message=str_replace("\\","",$_POST["question"]); //envoi des mails - $headers = makeHeaders() ; if (isset($_POST['adresse_mail']) && !empty($_POST['adresse_mail']) && validateEmail($_POST['adresse_mail'])) { - $headers .= "\r\n".'Reply-To: '.$_POST['adresse_mail']; + $headers = 'Reply-To: '.$_POST['adresse_mail']; + } else { + $headers = '' ; } + sendEmail( ADRESSEMAILADMIN, "" . _("[CONTACT] You have sent a question ") . "".NOMAPPLICATION, "" . _("You have a question from a user ") . " ".NOMAPPLICATION."\n\n" . _("User") . " : ".$_POST["nom"]."\n\n" . _("User's email address") . " : $_POST[adresse_mail]\n\n" . _("Message") . " :".$message,$headers ); if (isset($_POST['adresse_mail']) && !empty($_POST['adresse_mail']) && validateEmail($_POST['adresse_mail'])) { - $headers = makeHeaders() ; - sendEmail( "$_POST[adresse_mail]", "" . _("[COPY] Someone has sent a question ") . "".NOMAPPLICATION, "" . _("Here is a copy of your question") . " :\n\n".$message." \n\n" . _("We're going to answer your question shortly.") . "\n\n" . _("Thanks for your confidence.") . "\n".NOMAPPLICATION,$headers ); + sendEmail( "$_POST[adresse_mail]", "" . _("[COPY] Someone has sent a question ") . "".NOMAPPLICATION, "" . _("Here is a copy of your question") . " :\n\n".$message." \n\n" . _("We're going to answer your question shortly.") . "\n\n" . _("Thanks for your confidence.") . "\n".NOMAPPLICATION ); } //affichage de la page de confirmation d'envoi diff --git a/creation_sondage.php b/creation_sondage.php index 648be34..f0e2d40 100644 --- a/creation_sondage.php +++ b/creation_sondage.php @@ -82,8 +82,6 @@ function ajouter_sondage() $date_fin = time()+15552000; } - $headers = makeHeaders() ; - global $connect; $sql = 'INSERT INTO sondage @@ -118,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, $headers ); - sendEmail( "$_SESSION[adresse]", "[".NOMAPPLICATION."][" . _("For sending to the polled users") . "] " . _("Poll") . " : ".stripslashes(htmlspecialchars_decode($_SESSION["titre"],ENT_QUOTES)), $message, $headers ); + 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 ); } $date=date('H:i:s d/m/Y:'); diff --git a/fonctions.php b/fonctions.php index 169a538..89aa52b 100644 --- a/fonctions.php +++ b/fonctions.php @@ -183,28 +183,21 @@ function sendEmail( $to, $subject, $body, $headers, $param) } ; $subject = '=?UTF-8?B?' . base64_encode( html_entity_decode( $subject, ENT_QUOTES, 'UTF-8' ) ) . '?=' ; + + $encoded_app = '=?UTF-8?B?' . base64_encode( NOMAPPLICATION ) . '?=' ; + + 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" + $headers .= "Content-Transfer-Encoding: 8bit" + $body = html_entity_decode( $body, ENT_QUOTES, 'UTF-8' ) ; mail( $to, $subject, $body, $headers, $param ) ; } -function makeHeaders() { - - $headers_str = << -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit -EOF; - - $encoded_app = '=?UTF-8?B?' . base64_encode( NOMAPPLICATION ) . '?=' ; - $headers = sprintf( $headers_str, $encoded_app, ADRESSEMAILADMIN ) ; - - return $headers ; - -} - /** * Fonction vérifiant l'existance et la valeur non vide d'une clé d'un tableau diff --git a/studs.php b/studs.php index c74052b..fd89460 100644 --- a/studs.php +++ b/studs.php @@ -171,14 +171,12 @@ if (!is_error(NO_POLL) && (isset($_POST["boutonp"]) || isset($_POST["boutonp_x"] $connect->Execute($sql, array($nom, $numsondage, $nouveauchoix)); if ($dsondage->mailsonde || /* compatibility for non boolean DB */ $dsondage->mailsonde=="yes" || $dsondage->mailsonde=="true") { - $headers = makeHeaders() ; sendEmail( "$dsondage->mail_admin", "[".NOMAPPLICATION."] "._("Poll's participation")." : ".html_entity_decode($dsondage->titre, ENT_QUOTES, 'UTF-8')."", html_entity_decode("\"$nom\" ", ENT_QUOTES, 'UTF-8'). _("has filled a line.\nYou can find your poll at the link") . " :\n\n". getUrlSondage($numsondage)." \n\n" . - _("Thanks for your confidence.") . "\n". NOMAPPLICATION, - $headers ); + _("Thanks for your confidence.") . "\n". NOMAPPLICATION ); } } } else { @@ -307,8 +305,7 @@ if ($testmodifier) { $connect->Execute($sql, array($nouveauchoix, $data->nom, $data->id_users)); if ($dsondage->mailsonde=="yes") { - $headers = makeHeaders() ; - sendEmail( "$dsondage->mail_admin", "[".NOMAPPLICATION."] " . _("Poll's participation") . " : ".html_entity_decode($dsondage->titre, ENT_QUOTES, 'UTF-8'), "\"".html_entity_decode($data->nom, ENT_QUOTES, 'UTF-8')."\""."" . _("has filled a line.\nYou can find your poll at the link") . " :\n\n".getUrlSondage($numsondage)." \n\n" . _("Thanks for your confidence.") . "\n".NOMAPPLICATION,$headers ); + sendEmail( "$dsondage->mail_admin", "[".NOMAPPLICATION."] " . _("Poll's participation") . " : ".html_entity_decode($dsondage->titre, ENT_QUOTES, 'UTF-8'), "\"".html_entity_decode($data->nom, ENT_QUOTES, 'UTF-8')."\""."" . _("has filled a line.\nYou can find your poll at the link") . " :\n\n".getUrlSondage($numsondage)." \n\n" . _("Thanks for your confidence.") . "\n".NOMAPPLICATION ); } } From a84355c43880a78f460153349a2c3b1a380fa56f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Gu=C3=A9rard?= Date: Wed, 11 Jan 2012 20:45:13 +0100 Subject: [PATCH 09/15] Add some missing semicolon --- fonctions.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fonctions.php b/fonctions.php index 89aa52b..521ef69 100644 --- a/fonctions.php +++ b/fonctions.php @@ -186,11 +186,11 @@ function sendEmail( $to, $subject, $body, $headers, $param) $encoded_app = '=?UTF-8?B?' . base64_encode( NOMAPPLICATION ) . '?=' ; - 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" - $headers .= "Content-Transfer-Encoding: 8bit" + 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" ; + $headers .= "Content-Transfer-Encoding: 8bit" ; $body = html_entity_decode( $body, ENT_QUOTES, 'UTF-8' ) ; 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 10/15] 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' ) ; From 12a07f14071ea155526298bb264aef7ed9ec78d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Gu=C3=A9rard?= Date: Wed, 18 Jan 2012 00:29:57 +0100 Subject: [PATCH 11/15] Fix the mb_encode_mimeheader call syntax --- fonctions.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fonctions.php b/fonctions.php index b5b4819..e07405f 100644 --- a/fonctions.php +++ b/fonctions.php @@ -167,20 +167,20 @@ function validateEmail($email) function sendEmail( $to, $subject, $body, $headers, $param) { - $subject = mb_encode_mimeheader( html_entity_decode( $subject, ENT_QUOTES, 'UTF-8' ), "UTF-8",,, 9 ) ; + $subject = mb_encode_mimeheader( html_entity_decode( $subject, ENT_QUOTES, 'UTF-8' ), "UTF-8", "B", "\r\n", 9 ) ; - $encoded_app = mb_encode_mimeheader( NOMAPPLICATION, "UTF-8",,, 6 ) ; + $encoded_app = mb_encode_mimeheader( NOMAPPLICATION, "UTF-8", "B", "\r\n", 6 ) ; $size_encoded_app = strlen( $encoded_app ) % 76 ; $size_admin_email = strlen( ADRESSEMAILADMIN ) ; - if ( $size_encoded_app + $size_admin_email + 9 > 74 ) $folding = "\n" + if ( $size_encoded_app + $size_admin_email + 9 > 74 ) $folding = "\r\n" else $folding = "" ; $from = sprintf( "From: %s%s <%s>\n", $encoded_app, $folding, ADRESSEMAILADMIN ) ; - if ( $headers ) $headers .= "\n" ; + if ( $headers ) $headers .= "\r\n" ; $headers .= $from ; - $headers .= "MIME-Version: 1.0\n" ; - $headers .= "Content-Type: text/plain; charset=UTF-8\n" ; + $headers .= "MIME-Version: 1.0\r\n" ; + $headers .= "Content-Type: text/plain; charset=UTF-8\r\n" ; $headers .= "Content-Transfer-Encoding: 8bit" ; $body = html_entity_decode( $body, ENT_QUOTES, 'UTF-8' ) ; From 3908d13b4afd9b3c5383856ded296b68ed056e41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Gu=C3=A9rard?= Date: Wed, 18 Jan 2012 00:33:42 +0100 Subject: [PATCH 12/15] Another syntax fix --- fonctions.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fonctions.php b/fonctions.php index e07405f..e87673c 100644 --- a/fonctions.php +++ b/fonctions.php @@ -173,8 +173,11 @@ function sendEmail( $to, $subject, $body, $headers, $param) $size_encoded_app = strlen( $encoded_app ) % 76 ; $size_admin_email = strlen( ADRESSEMAILADMIN ) ; - if ( $size_encoded_app + $size_admin_email + 9 > 74 ) $folding = "\r\n" - else $folding = "" ; + if ( $size_encoded_app + $size_admin_email + 9 > 74 ) { + $folding = "\r\n" ; + } else { + $folding = "" ; + } ; $from = sprintf( "From: %s%s <%s>\n", $encoded_app, $folding, ADRESSEMAILADMIN ) ; if ( $headers ) $headers .= "\r\n" ; From 86fc583c262fc8d9396f646e5545039eaea3e182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Gu=C3=A9rard?= Date: Wed, 18 Jan 2012 00:41:23 +0100 Subject: [PATCH 13/15] Force multibyte functions internal encoding --- fonctions.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fonctions.php b/fonctions.php index e87673c..a850d04 100644 --- a/fonctions.php +++ b/fonctions.php @@ -167,6 +167,8 @@ function validateEmail($email) function sendEmail( $to, $subject, $body, $headers, $param) { + mb_internal_encoding("UTF-8"); + $subject = mb_encode_mimeheader( html_entity_decode( $subject, ENT_QUOTES, 'UTF-8' ), "UTF-8", "B", "\r\n", 9 ) ; $encoded_app = mb_encode_mimeheader( NOMAPPLICATION, "UTF-8", "B", "\r\n", 6 ) ; From 87c0dd21f6429bbcf6358bdeaf986955b2e21841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Gu=C3=A9rard?= Date: Wed, 18 Jan 2012 00:45:31 +0100 Subject: [PATCH 14/15] Replace CRLF in headers by LF --- fonctions.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fonctions.php b/fonctions.php index a850d04..99ea641 100644 --- a/fonctions.php +++ b/fonctions.php @@ -169,23 +169,23 @@ function sendEmail( $to, $subject, $body, $headers, $param) mb_internal_encoding("UTF-8"); - $subject = mb_encode_mimeheader( html_entity_decode( $subject, ENT_QUOTES, 'UTF-8' ), "UTF-8", "B", "\r\n", 9 ) ; + $subject = mb_encode_mimeheader( html_entity_decode( $subject, ENT_QUOTES, 'UTF-8' ), "UTF-8", "B", "\n", 9 ) ; - $encoded_app = mb_encode_mimeheader( NOMAPPLICATION, "UTF-8", "B", "\r\n", 6 ) ; - $size_encoded_app = strlen( $encoded_app ) % 76 ; + $encoded_app = mb_encode_mimeheader( NOMAPPLICATION, "UTF-8", "B", "\n", 6 ) ; + $size_encoded_app = strlen( $encoded_app ) % 75 ; $size_admin_email = strlen( ADRESSEMAILADMIN ) ; if ( $size_encoded_app + $size_admin_email + 9 > 74 ) { - $folding = "\r\n" ; + $folding = "\n" ; } else { $folding = "" ; } ; $from = sprintf( "From: %s%s <%s>\n", $encoded_app, $folding, ADRESSEMAILADMIN ) ; - if ( $headers ) $headers .= "\r\n" ; + if ( $headers ) $headers .= "\n" ; $headers .= $from ; - $headers .= "MIME-Version: 1.0\r\n" ; - $headers .= "Content-Type: text/plain; charset=UTF-8\r\n" ; + $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' ) ; From caf84064df23bd66e30005e61baa83c2f384a282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20Gu=C3=A9rard?= Date: Wed, 18 Jan 2012 00:51:23 +0100 Subject: [PATCH 15/15] Fix last header line size calculation The "From: " prefix size was not taken into accounts when calculating how many characters were on the last header line produced by mb_encode_mimeheader. This is used to check if the e-mail address should be placed on a separate line. --- fonctions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fonctions.php b/fonctions.php index 99ea641..059d639 100644 --- a/fonctions.php +++ b/fonctions.php @@ -172,10 +172,10 @@ function sendEmail( $to, $subject, $body, $headers, $param) $subject = mb_encode_mimeheader( html_entity_decode( $subject, ENT_QUOTES, 'UTF-8' ), "UTF-8", "B", "\n", 9 ) ; $encoded_app = mb_encode_mimeheader( NOMAPPLICATION, "UTF-8", "B", "\n", 6 ) ; - $size_encoded_app = strlen( $encoded_app ) % 75 ; + $size_encoded_app = ( 6 + strlen( $encoded_app ) ) % 75 ; $size_admin_email = strlen( ADRESSEMAILADMIN ) ; - if ( $size_encoded_app + $size_admin_email + 9 > 74 ) { + if ( ( $size_encoded_app + $size_admin_email + 9 ) > 74 ) { $folding = "\n" ; } else { $folding = "" ;