I try to include a numerical variable from a database into a mail, using utf-8 encoding.
Here is the php code:
$req = $bdd->prepare('SELECT prix FROM offres WHERE rang=?');
$req->execute(array(1));
$donnees=$req->fetch();
$passage_ligne = "\n";
$v = 10.15;
$text='essai1 = '.$v;
$text.=$passage_ligne;
$text.= 'essai2 = '.$donnees['prix'];
$text.=' here is a french accent: é';
$v=$donnees['prix'];
$text.=$passage_ligne."essai3 = ".$v;
echo $text;
$from='xxx@wanadoo.fr';
$replyto='xxx@wanadoo.fr';
$Xmailer='PHP/';
$header = 'From: '. $from . $passage_ligne .'Reply-To: '. $replyto . $passage_ligne .'X-Mailer: '. $Xmailer . phpversion();
$header.= "MIME-Version: 1.0". $passage_ligne;
$header.= "Content-Type: text/plain; charset=utf-8". $passage_ligne;
$header.= "Content-Transfer-Encoding: quoted-printable". $passage_ligne;
$passage_ligne .'X-Mailer: '. $Xmailer . phpversion();
mail('xxxr@wanadoo.fr','sujet',$text,$header);
The numerical variable $donnees['prix'] = 18 does show up on the screen:
essai1 = 10.15 essai2 = 18 here is a french accent: é essai3 = 18
But not in the mail, where it is truncated to "8":
essai1 = 10.15
essai2 =8 here is a french accent: é
essai3 =8
If I use the following header:
$header = 'From: '. $from . $passage_ligne .'Reply-To: '. $replyto . $passage_ligne .'X-Mailer: '. $Xmailer . phpversion();
The numerical variable shows up corectly in the mail, but not the accents:
essai1 = 10.15
essai2 = 18 here is a french accent: é
essai3 = 18
Any way to get both in the same mail ? - Thanks