accented characters in email fields
I'm using this script to have email sent to me through a mail form:
<?php
// initialize variables for To and Subject fields
$to = 'info@testing.nl';
$subject = 'Een testmail';
$from = $_POST["from"];
$email = $_POST["email"];
$comments = $_POST["comments"];
// build message body from variables received in the POST array
$message = "Van: $from \n\n";
$message .= "Email: $email \n\n";
$message .= "Bericht: $comments";
$message = stripslashes($message);
//convert flash line breaks
$message= str_replace("\r", "\n", $message);
$message=nl2br($message);
// add additional email headers for more user-friendly reply
$additionalHeaders = "From: $from <".$email.">\r\n";
$additionalHeaders .= "Reply-To: ".$email."\r\n";
$additionalHeaders .= "MIME-Version: 1.0\r\n";
$additionalHeaders .= "Content-type: text/html; charset=utf-8\r\n";
// send email message
$OK = mail($to, $subject, $message, $additionalHeaders);
// let Flash know what the result was
if ($OK) {
echo 'sent=OK';
}
else {
echo 'sent=failed&reason='. urlencode('Er is een probleem met de server. Probeer het later nog eens.');
}
?>
The problem is that I can't get accented characters appear into the From: cc: bcc: fields. For example, when I fill the From field with 'René' it appears as 'RenX' in the From: field. I've set everything to utf-8 but that doesn't seem to matter. When I receive an html text mail, the From: fields displays accented characters as strange codes, like RenA@ or RenX for René.
In the message text itself it varies: it either displays René when the mail is viewed as plain text mail, or RenA@ when the mail is views as html text. How can I get accented characters appear inside email fields too? And also in the body text when the email is viewed as html text?
