Russian characters in mail()

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi everybody,

could anybody kindly give me a hint for dealing with the following
problem :

I need to send e-mails from a PHP 5 script running on Windows Apache,
containing Russian characters in the subject and in the content. I use
the function mail($to,$subject,$content,$header). The header looks like
this now : "From:\r\nX-Mailer:
PHP/".phpversion()."\r\nContent-Type: text/plain; charset='utf-8'"

Regrettably, the result is not much encouraging : I receive only
unreproducable characters on the other (receiver) side...

How to tackle this?

Thanks in advance


Re: Russian characters in mail()


on 10/31/2006 07:03 PM Victor said the following:
Quoted text here. Click to load it

The content type character set only applies to the body. Headers must
encoded individually with q-encoding.

You may want to take a look at this class that can encode headers and
bodies properly as needed. Just use the default_charset class variable
to utf-8 and the whole message will be encoded properly. Take a look at
the test_email_message.php example for a pratical example.


Manuel Lemos

Metastorage - Data object relational mapping layer generator

PHP Classes - Free ready to use OOP components written in PHP

Re: Russian characters in mail()

Hi Manuel,

thank you very much for your encoding class. It works apparently great.
Unfortunately, the mails produced by it, do not get delivered by my
email provider.
You know, the mails generated with my code do get, and the mails
generated with your class do not. Though, the function
$email_message->Send() does not report any errors.

Could you suggest an idea about what may cause this?


Site Timeline