What is the issue with sending emails in Windows-1251 encoding in PHP?

When sending emails in Windows-1251 encoding in PHP, some email clients may not display the content correctly due to character encoding issues. To solve this problem, you can convert the content to UTF-8 encoding before sending the email.

// Convert content to UTF-8 encoding
$content = iconv('Windows-1251', 'UTF-8', $content);

// Set the email headers to specify UTF-8 encoding
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=UTF-8" . "\r\n";

// Send the email
mail($to, $subject, $content, $headers);