I’ve made a flash mailform. This communicates with below script to send the mail. Which works ok. I’ve used utf8_decode to also make it send accented characters like ë á é ü etc. In the message field this works ok. All accented characters display. In the ‘from’ field however, these accented characters still appear funny. Like when it should display ‘René’ in the from-field, it displays ‘renX’ in the from-field. In the message field is still display’s René.
What do I have to do to also make it work in the from-field?
<?php
// initialize variables for To and Subject fields
$to = 'info@test.nl';
$subject = 'Een vraag';
$from = stripslashes(utf8_decode($_POST['from']));
$email = stripslashes(utf8_decode($_POST['email']));
$comments = stripslashes(utf8_decode($_POST['comments']));
// build message body from variables received in the POST array
$message = 'Van: ' . $from . "\
\
";
$message .= 'Email: '. $email ."\
\
";
$message .= 'Bericht: '. $comments;
//convert flash line breaks
$message = ereg_replace("\\r", "\
", $message);
// add additional email headers for more user-friendly reply
$additionalHeaders = "MIME-Version: 1.0\\r\
";
$additionalHeaders .= "Content-type: text/html; charset= ISO 8859-1\\r\
";
$additionalHeaders .= "From: " . $from ." <" . $email . ">\\r\
";
$additionalHeaders .= "Reply-To: " . $email;
// 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.');
}
?>
Don’t think so? I had to use utf8_decode on the output from flash cause flash sends it’s output in utf8. Otherwise accented characters from the flash form would turn into strange codes. So that turns the utf8 output from flash into ISO 8859-1 for php. And in the message field of the email, these accented characters appear ok now. Accept in the from field of the email. René now turns into RenXX