...

View Full Version : mail.php file does not support Russian characters



maloney
11-24-2010, 10:37 PM
How can i make the mail.php file below work with russian characters?

<?
$name=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$city=$_POST['city'];
$message=$_POST['message'];
$ToEmail = "xxxxxxxxxxxxxxxx@usa.net";
$ToSubject = "Message from your site";
$EmailBody = "Name: $name\n
Email: $email\n
Phone: $phone\n
City: $city\n
Message: $message\n";
$Message = $EmailBody;
$headers .= "Content-type: text; charset=iso-8859-1\r\n";
$headers .= "From:".$name." / ".$email."\r\n";

mail($ToEmail,$ToSubject,$Message, $headers);
?>

THanks

maloney
11-25-2010, 12:03 AM
any help would be appreciated

low tech
11-25-2010, 12:50 AM
Hi

I'm not a pro coder --- but I have had similar problem with Chinese

anyway you could try to change your charset

charset=utf8

torrjuck
11-25-2010, 01:20 AM
Add this to your <head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
With the iso for russia. iso-8859-1 is for swedish.

Fou-Lu
11-25-2010, 01:39 AM
The meta won't work with a mail command; that one may work with the display though. Generally I find I need to push an actual content header from PHP to get it to understand >.<
The charset change on the mail header should do the trick. Though I recall quite a ways back someone posting some problems that ended up being an issue with their webhost itself and not PHP.

I can't wait for PHP 6 when it should support native unicode.


Actually, with the meta I think I got what you mean there. It *may* work in the HTML processing from the client itself. But I have a feeling that the transfer will stomp it when the charset itself is incorrect.

maloney
11-27-2010, 01:01 AM
Thanks, for all the advice, after some testing I got it working

Below the modified and working code
Note that you must save the mail.php file as UTF-8 , which can be done in notepad.

To get the Russian text working i needed to change the charset to UTF-8

<?
$name=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$city=$_POST['city'];
$message=$_POST['message'];

$ToEmail = "aaaa@xxxx.com";
$ToSubject = "Message from your site";

$EmailBody = "Name: $name\n
Email: $email\n
Phone: $phone\n
City: $city\n
Message: $message\n";

$Message = $EmailBody;


$headers .= "Content-type: text; charset=UTF-8\r\n";
$headers .= "From:".$name." / ".$email."\r\n";

mail($ToEmail,$ToSubject,$Message, $headers);

?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum