Fix encoding of the From header

This commit is contained in:
Jean-Philippe Guérard 2012-01-09 02:18:25 +01:00
parent 1059a4108a
commit f8f277e929
5 changed files with 25 additions and 13 deletions

View File

@ -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 = <<<EOF
From: %s <%s>
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,

View File

@ -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 );
}

View File

@ -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;

View File

@ -188,6 +188,22 @@ function sendEmail( $to, $subject, $body, $headers, $param)
}
function makeHeaders() {
$headers_str = <<<EOF
From: %s <%s>
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

View File

@ -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 );
}
}