The problem is that the Russian letters in the header From come to Yandex mail in the form of krakozyabr. Everything comes to other mail services correctly. Where, when sending a letter, you can specify the encoding specifically for this header?
Or maybe you need to put a different encoding throughout the letter? I send the standard header:

 Content-Type: text/html; charset=utf-8\r\n 
  • If you strictly adhere to the RFC, then 8-bit characters in any letter header are not allowed . They need to be encoded and for each such field to write in what encoding is the given header field . - avp
  • Is it possible in a bit more detail how to do this? - andreyqin
  • Try to start with this . And it is better to send everyone with Russian letters in the headers of the e-mail ... - avp
  • Too hard :(. I need to encode just 1 word and it should be in Russian. - andreyqin
  • The comment did not fit. He gave an example in the answer. - avp

2 answers 2

@andreyqin , just for the "one word" example from the RFC, which I suggested to read to you

 From: =?US-ASCII*EN?Q?Keith_Moore?= <moore@cs.utk.edu> 

And also go from there to RFC 2047

and read

 2. Syntax of encoded-words 4. Encodings 

Here, for example for

 this is some text 

we get

 =?iso-8859-1?q?this=20is=20some=20text?= 

Those. do

 =?ΠΊΠΎΠ΄ΠΈΡ€ΠΎΠ²ΠΊΠ°?q?q-ΠΊΠΎΠ΄ΠΈΡ€ΠΎΠ²Π°Π½Π½Ρ‹ΠΉ-тСкст?= 

The idea of ​​the Q encoding is simple, all but the Latin letters and numbers are replaced by = XX (XX - 16-byte code). Instead of iso-8859-1, write your own encoding (for example, UTF-8).

  • @avp, I confess, but I'm not very friendly with English. And the problem was solved, here's the code: $ headers. = "From: =? CP1251? B?" . base64_encode (iconv ('UTF-8', 'CP1251', 'Word in Russian')). "? = \ r \ n"; - andreyqin
  • one
    Well, I do not write on PCP, but if it's easier for you, then yes, instead of Q-B-coding. Why transcode UTF to CP1251? Extra work. Also note that in cp1251 you can encode only Russian characters (+ some more characters), and in UTF any. In addition, if in the source text in utf there are characters that cannot be represented in cp1251, then iconv will most likely return an error instead of text. But, as it is real in PCP - it is necessary to check. - avp

Look at something like this http://www.php.net/manual/ru/function.mail.php#111124 I was saved in a similar situation base64

  • Tried base64 - the whole letter becomes krakozabrami. I went to the forehead and made $ from = iconv ("UTF-8", "Windows-1251", "String"); $ headers = "Content-Type: text / html; charset = utf-8 \ r \ n"; $ headers. = "From: $ from \ r \ n"; But in this case, no header comes to mail.ru at all. - andreyqin
  • encode base64 as described in rfc, - zb '