PHP mail messing up Russian characters

I have a client that uses PHP's mail() function to send mail from a contact form. The problem is, if a Russian user uses it, the mail that is received by the client has messed up characters instead of the Russian characters.

When he tests it on the development server it works, but when on the live server it does that.

Any ideas other than "rather use this PHP mailer script"?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I'm by no means an expert with the PHP's mail() command and prefer writing simple SMTP communication scripts with authentication support and such, but I'm quessing the character set can be messed up by either the production server's PHP configuration or the SMTP server. You could try different approaches based on whether the message is sent in text/plain or text/html.

If in text/plain, be sure to use the set_locale() command to override the server's default character set and specify the mail header:
Content-type: text/plain; charset=utf-8

If sending text/html, you could always htmlentities() the entire message to be double sure, do the previous tricks and also include a HTML meta tag
<meta http-equiv="Content-Type" content="text/html charset=utf-8" />
of course the mail header should then be:
Content-type: text/html; charset=utf-8

Hope this'll get you closer to a solution.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
You need to convert all chars in header to an hexadecimal.
Maybe this will work for you or will give you a clue to solve your trouble

	function charsToHex($string) {
		return preg_replace("#([ãáàâäéèêëíìîïõóòôöúùûüçñ])#ie",'"=". dechex(ord("\\1"))' .'"="',$string);
$subject = "=?iso-8859-1?Q?" . charsToHex($subject) . "?=";

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.