What are the potential pitfalls of using ISO-8859-1 encoding in PHP mail?

Potential pitfalls of using ISO-8859-1 encoding in PHP mail include character encoding issues for non-Latin characters, which can result in garbled or unreadable content for recipients using different character sets. To solve this issue, it's recommended to use UTF-8 encoding for better compatibility across different languages and character sets.

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

// Send the email with UTF-8 encoding
mail($to, $subject, $message, $headers);