I send the letter to myself by mail. in the utf-8 encoding, and sometimes such artifacts occur, I can not understand because of what?

$headers = "Content-type: text/html; charset=utf-8 \r\n"; mail($to, $subject, $message, $headers); 

These things sometimes come out and break everything.

  <t! d> 

in tags, in lines, climbs out! sign

  • check the encoding of the file. php - tCode
  • checked utf 8 without bom - mydls1

1 answer 1

In the header you need to add MIME-Version: 1.0

 $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; mail($to, $subject, $message, $headers); 

The mail () function. Why send a header with the letter "MIME-Version: 1.0"?

  • did not fit, still climbs anyway! - mydls1
  • <td> & lt; td! & gt; 4333 </ td> that's what it does. as if duplicated tags and re-encrypted. while in the code that generates the body of the letter, there are no errors - mydls1
  • @ mydls1 error in the HTML itself? - tCode
  • 10 lines are normal, 1 with artifact, there is such a code - mydls1
  • $ insertProductTable. = '<tr> <td>'. $ lastID. '</ td> <td>'. $ sku. '</ td> <td>'. $ category. '</ td> <td> '. $ name.' </ td> <td> '. $ manufacturer_name. '</ td> <td>'. $ price. '</ td> <td>'. $ quantity. '</ td> </ tr>'; - mydls1