Probléme d'accent

herve64200 -  
 herve64200 -
j'ai un ptit probleme. J'ai un formulaire qui permet d'envoyer un mail a partir de mon site. Les accents (é,è,à...) ne s'affichent pas dans le mail.
Pouvez vous m'aider svp.

ci joint mon script.

<?php

require_once('./init.php');

function sendMail($to, $fromaddress, $subject, $body, $attachments=false)
{
$eol="\r\n";
$mime_boundary=md5(time());

# Common Headers
$headers .= "From: ".$fromaddress.$eol;
$headers .= "Reply-To: ".$fromaddress.$eol;
$headers .= "Return-Path: ".$fromaddress.$eol;
$headers .= "Message-ID: <".time()."-".$fromaddress.">".$eol;
$headers .= "X-Mailer: PHP v".phpversion().$eol;

# Boundry for marking the split & Multitype Headers
$headers .= 'MIME-Version: 1.0'.$eol;
$headers .= "Content-Type: text/plain; charset=utf-8".$eol;

# Open the first part of the mail
$msg = "--".$mime_boundary.$eol;

$htmlalt_mime_boundary = $mime_boundary."_htmlalt";
$msg .= "Content-Type: multipart/alternative; boundary=\"".$htmlalt_mime_boundary."\"".$eol.$eol;

# Text Version
$msg .= "--".$htmlalt_mime_boundary.$eol;
$msg .= "Content-Type: text/plain; charset=utf-8".$eol;
$msg .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
$msg .= strip_tags(str_replace("<br>", "\n", substr($body, (strpos($body, "<body>")+6)))).$eol.$eol;

# HTML Version
$msg .= "--".$htmlalt_mime_boundary.$eol;
$msg .= "Content-Type: text/html; charset=utf-8".$eol;
$msg .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
$msg .= $body.$eol.$eol;

//close the html/plain text alternate portion
$msg .= "--".$htmlalt_mime_boundary."--".$eol.$eol;

if ($attachments !== false && count($attachments['name']) > 0)
{
for ($i = 0; $i < count($attachments['name']); $i++) {
if (is_file($attachments["tmp_name"][$i]))
{
# File for Attachment
$handle = fopen($attachments["tmp_name"][$i], 'rb');
$f_contents = fread($handle, filesize($attachments["tmp_name"][$i]));
$f_contents = chunk_split(base64_encode($f_contents));
fclose($handle);

# Attachment
$msg .= "--".$mime_boundary.$eol;
$msg .= "Content-Type: ".$attachments["type"][$i]."; name=\"".$attachments['name'][$i]."\"".$eol;
$msg .= "Content-Transfer-Encoding: base64".$eol;
$msg .= "Content-Description: ".$attachments['name'][$i].$eol;
$msg .= "Content-Disposition: attachment; filename=\"".$attachments['name'][$i]."\"".$eol.$eol;
$msg .= $f_contents.$eol.$eol;
}
}
}

$msg .= "--".$mime_boundary."--".$eol.$eol;

ini_set(sendmail_from, $fromaddress);
$mail_sent = mail($to, $subject, $msg, $headers);

ini_restore(sendmail_from);

return $mail_sent;
}

parse_str(trim(file_get_contents(DIR_ROOT.$_POST['pathForm'])), $out);
foreach ($out as $k=>$v) {
$out[$k] = urldecode($v);
}

$message = '';
for ($i = 1; $i <= 4; $i ++){
$message .= '<b>'.$out['field'.$i].'</b>: '.nl2br(Core::StrT($_POST['field'.$i])).'<br />';
}

sendMail($out['email'], 'contact.form@'.$_SERVER['SERVER_NAME'], 'Contact form', $message);

2 réponses

bast64 Messages postés 47 Statut Membre 3
 
As tu essayé de changer ton doctype en remplaçant
$msg .= "Content-Type: text/plain; charset=utf-8".$eol;
par
$msg .= "Content-Type: text/plain; charset=iso-8859-15".$eol;
0
herve64200
 
j'ai essayé en changeant

$msg .= "Content-Type: text/plain; charset=utf-8".$eol;

par

$msg .= "Content-Type: text/plain; charset=iso-8859-15".$eol;

mon prob n'est pas résolu
0
herve64200
 
j'ai essayé en changeant

$msg .= "Content-Type: text/plain; charset=utf-8".$eol;

par

$msg .= "Content-Type: text/plain; charset=iso-8859-15".$eol;

j'ai toujours le même probléme
0