Jump to content

accented characters in mail


digitalecartoons

Recommended Posts

I've made a flash form which uses this script to send the input by mail:

<?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.');
  }
?>

 

Works a bit besides accented characters like é ë ä ó ö ú etc. For example: when I use 'René' in the From field it arrives like 'RenX', but in text mode as in html mode. The From fiels displays 'RenX' I mean.

 

When in text mode, the body text of the email displays 'René' however.

 

When I view the mail in html mode, it also displays 'RenX' in the From field, but the body text displays 'rené'.

 

How to I make it display René both in the From field and the body text? And both in text mode as in html mode?

Link to comment
https://forums.phpfreaks.com/topic/195146-accented-characters-in-mail/
Share on other sites

I would suggest that you use an email client that you know works and send yourself a message with the correct information in it.

 

Then when it gets to you, have a look at the message source and find out how it is done. Probably setting character encoding in a different place or something like that?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.