There is a script that sends an e-mail notification, notifications come in the form of cracks instead of Russian text.

utf-8 without pto is in notepad++ , mysql tables are utf-8, in php files utf-8 is indicated everywhere, so not on the site not in the database there are no problems with encoding, here come the email messages except for the subject of the letter, the content of the letter and the output with mysql in the letter contains these funny characters п╢я─п╟п╟п╟п╟п╟я│я┌п╣ я▀п╡п╟п╡п╟

 function email($to, $subject, $body) { mail($to, $subject, $body, 'From: mail@mail.ru'); } function register_user($query) { array_walk($query, 'array_sanitize'); $query['password']= md5($query['password']); $fields = '`' . implode('`, `',array_keys($query)) . '`'; $data = '\'' . implode('\', \'', $query) . '\''; mysql_query("INSERT INTO `users` ($fields) VALUES ($data)"); email($query['email'], 'активация аккаунта', "приветствуем" . $query['first_name'] . "\n\nпройдите по следущей ссылке для завершения регистрации :\n\n ".PATH."www/activate.php?email=" . $query['email'] . "&email_code=".$query['email_code'] ."\n\n- "); } 

Account activation - comes in a normal form, all other content is unknown to science symbols

    2 answers 2

    These symbols are very well known to science: it is UTF-8, interpreted as KOI8-R. A letter is read like this, because the sender does not know that the charset should be indicated in the letters.

    • which header ('Content-type: text / html; charset = utf-8'); <meta charset = "UTF-8"> mysql_query ("SET NAMES 'utf8'"); mysql_query ("SET CHARACTER SET 'utf8'"); or rather which one is it? - LLIAKAJI
    • one
      The header, which is described in RFC-822, and which is set up as in example number 2 in the "mail () function" section of the PHP manual :) :) Something like this: mail ($ to, $ subj, $ text, 'Content-Type : text / plain; charset = UTF-8 '); - user6550
    • mail ($ to, $ subj, $ text, 'Content-Type: text / plain; charset = UTF-8'); so the letter does not come at all mail ($ to, $ subject, $ body, 'From: mail@mail.ru', 'Content-Type: text / plain; charset = UTF-8'); so krakozyabry do not disappear anywhere - LLIAKAJI
    • All the problem was solved. It was necessary to put ANSI in notepad ++ in one place - LLIAKAJI
    • 2
      Are you copy-paste the example I gave, just like it is - with $ to, $ subj, $ text variables? - user6550 7:09 pm

    Without specifying charsets, simply convert Cyrillic to php to KOI8-U encoding:

     $msg_koi8 = iconv('utf-8','windows-1251',$msg);