greetings to all

$to = $massiv["to"]; $subject = $massiv["subject"]; $message = $massiv["message"]; $mailheaders = "Content-type: text/html; charset=windows-1251 \r\n"; $mailheaders .= "From: mysite.ru <no-reply@mysite.ru>"; $mailheaders .= "Reply-To: mysite.ru"; mail($to, $subject, $message, $mailheaders); 

Something like sending a letter. Is there any way to specify the encoding in the header of the letter?

    2 answers 2

    Not quite a question is clear, the encoding is already specified in mailheaders. The header encoding can be set like this:

    $subject = '=?koi8-r?B?'.base64_encode(convert_cyr_string($masssiv[subject], "w","k")).'?=';

    • Let's say without encoding the letter did not correctly reach mail.ru. With the encoding, the problem has passed. But in Opera (browser), there is a built-in mail kelent. Here he letters come with an incomprehensible title and clear text. So I want to fix the headline. I apologize, the first time I see such a construct for changing the encoding. Does this command change the encoding to koi-8? - frank
    • The bottom line is that part of email clients do not understand the win-1251 encoding in the header, so it needs to be translated to koi8. The proposed option is 100% working. However, in koi8 it is impossible to transfer, for example, the symbol No., for example, to form a heading like: "Order No. 121 is issued." Read the manual phpclub.ru/detail/article/mail here is everything to send a message in the correct encoding. - Sharp - eyed
    • All of them have long been well understood, at least UTF8, at least cp1251. You only need to correctly specify the charset, and not send the Subject without encoding. - user6550

    A letter in text / html means, as usual:

     $message = "<html><head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251" </head><body> ..."; 
    • @klopp this for the header does not help. In the letter itself, I have done so. Specifically, the title interests - frank
    • one
      Then from the very beginning: what is your “letter header”? If you mean the Subject field, then everything is as it said @ Sharpness. To google according to mime subject encoding, the first links will tell in detail. - user6550