0

I have a php contact form that im using on my website but i want to enable the form to accept Cyrilic letters, because now if i use cyrilic i recive on the mail message this chars: ТеÑтовое

Here is my script:

    <?php

// load the variables form address bar
$subject = $_POST["subject"];
$message = $_POST["message"];
$from = $_POST["from"];
$verif_box = $_POST["verif_box"];

// remove the backslashes that normally appears when entering " or '
$message = stripslashes($message); 
$subject = stripslashes($subject); 
$from = stripslashes($from); 

// check to see if verificaton code was correct
if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
    // if verification code was correct send the message and show this page
    mail("[email protected]", 'Online Form: '.$subject, $_SERVER['REMOTE_ADDR']."\n\n".$message, "From: $from");
    // delete the cookie so it cannot sent again by refreshing this page
    setcookie('tntcon','');
} else if(isset($message) and $message!=""){
    // if verification code was incorrect then return to contact page and show error
    header("Location: index.php?subject=$subject&from=$from&message=".urlencode($message)."&wrong_code=true");
    exit;
} else {
    echo "no variables received, this page cannot be accessed directly";
    exit;
    }
?>
2
  • This is nothing we can easily answer, many points of failure come into view. In general: you must take care of the encoding, but there is not some magic command or anything that "enables" cyrillic characters. You'll have to check all steps envolved: the html form you send out, the capabilities of the browser used, the data sent back, then email headers and and and. Also, when checking those characters never trust any visualizing application, they all try to be smart and "interpret" instead of showing. Use a hexeditor for this, it is the only reliable type of application for such task.
    – arkascha
    May 28, 2014 at 16:40
  • Well, one things can be said: most likely the problem is the encoding specified in the email message you send. Probably you do not specify any encoding at all, so the clients have to guess which is theoretically impossible. I suggest you compare the source code of two messages you receive: a correct one (from an email client maybe) and one with the issue you describe. Check their source code and compare the headers you see. What is the difference?
    – arkascha
    May 28, 2014 at 16:41

1 Answer 1

0

It looks like your message is submitted as utf-8. Add the following header to your mail:

Content-Type: text/plain; charset=utf-8

Separate it with 1 newline from your "From"-header, i.e. "From: $from\nContent-Type: ..."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.