I send letters through the mail function (I tried the same thing through PHPmailer), some of the text of the letter is not substituted in the normal encoding, and another part in some unknown encoding.

Code:

$to = 'info@site.ru'; $hd="Content-Type: text/html; charset=utf-8\r\n"; $hd.="From: SITE.RU <info@site.ru>\r\n"; $hd.="X-Mailer: PHP/".phpversion()."\r\n"; $subject = 'Вам назначили задачу "'.$myrow_tasks['title'].'"!'; $mess=' <table cellpadding="0" cellspacing="0" border="0" align="center" style="margin:0;padding:0;width:700px;line-height:100%;border-collapse:collapse"> <tbody> <tr> <td valign="top" style="border-collapse:collapse"> <table cellpadding="5" cellspacing="0" border="0" align="center" style="background-color:#49769c;width:100%;color:white;font-family:sans-serif;margin-top:10px;padding:8px;border-collapse:collapse"> <tbody> <tr> <td width="115" height="50" valign="middle" style="border-collapse:collapse;margin:10px;"> <img src="http://site.ru/images/logo-150x47.png" alt="PLP" width="107" style="outline:none;margin:10px;text-decoration:none;display:block"> </td> <td width="200" valign="middle" style="padding-left:20px;border-collapse:collapse">- система обработки клиентов с вашего сайта</td> <td width="400" valign="middle" style="text-align:right;border-collapse:collapse"> <div style="margin-right:20px"> <a href=http://account.site.ru/login/ style="color:white" target="_blank">Вход в личный кабинет</a> </div> </td> </tr> </tbody> </table> <table cellpadding="0" cellspacing="0" border="0" align="center" style="border-collapse:collapse"> <tbody><tr> <td width="600" height="300px"; valign="middle" style="border-collapse:collapse"> <div style="margin:20px 10px"> Здравствуйте! <br><br> <h2>Вам поставили задачу "'.$myrow_tasks['title'].'".</h2> <br><br> Статус: '.$status_tasck.' <br><br> Дата начала: '.new_time(strtotime(''.$myrow_tasks['start_date'].' '.$myrow_tasks['start_time'].'')).' <br><br> Дата дедлайна: '.new_time(strtotime(''.$myrow_tasks['end_date'].' '.$myrow_tasks['end_time'].'')).' <br><br> Дата дедлайна: '.$myrow_tasks['description'].'; <br><br> <i style="color:#666">С уважением, команда сервиса SITE!</i> </div> </td> </tr> </tbody> </table> </td> </tr> <tr> <td valign="top" style="border-collapse:collapse"> <table cellpadding="5" cellspacing="0" border="0" style="background-color:#49769c;width:100%;color:white;font-family:sans-serif;margin-top:10px;border-collapse:collapse"> <tbody> <tr> <td valign="middle" align="left" style="width:130px;border-collapse:collaps;padding-left:20px;"> Присоединяйтесь: </td> <td valign="middle" align="left" style="width:35px;border-collapse:collapse;padding-left:5px;"> <a href="https://vk.com/" target="_blank" style=" padding-right:5px;"><img src="http://site.ru/images/vk_30px.jpg" alt="Вконтакте" width="30px" border="0" style="margin:5px;outline:none;text-decoration:none;" /></a> </td> <td valign="middle" align="left" style="width:35px;border-collapse:collapse;padding-left:5px;"> <a href="https://www.facebook.com/" target="_blank"><img src="http://site.ru/images/fb_30px.jpg" alt="FaceBook" width="30px" border="0" style="margin:5px;outline:none;text-decoration:none;" /></a> </td> <td valign="middle" align="left" style="width:35px;border-collapse:collapse;padding-left:5px;"> <a href="https://twitter.com/" target="_blank"><img src="http://site.ru/images/tw_30px.jpg" alt="Twitter" width="30px" border="0" style="margin:5px;outline:none;text-decoration:none;" /></a> </td> <td valign="middle" align="left" style="width:500px;border-collapse:collapse;padding-left:5px;"> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table>'; mail ($to,$subject,$mess,$hd); 

How to fix? Attached the incoming letter ... enter image description here

  • Because the upper part is in UTF-8 encoding (incorrect encoding), and the “hello” is in normal mail encoding KOI8-R (most likely this way). Mail functions often, unfortunately, require KOI8 encoding. - nick_n_a
  • @nick_n_a, how to fix this to work properly? - Alexander Sizintsev
  • It became even more fun =) i.gyazo.com/438a8a4896436640b5e355bace05e98a.png - Alexander Sizintsev
  • The top is exactly UTF-8. Bottom ... probably Windows-1251. In php there are functions to change the encoding. It is necessary to bring everything into one encoding (change the encoding of that part of the text that is displayed incorrectly). - nick_n_a
  • @nick_n_a, not well, this is a dicky pi ** yi i.gyazo.com/65b23d5134c77fe9dd918c1f39bcff92.png - Alexander Sizintsev

0