What potential issues can arise when using the PHP mail() function with HTML content?

When using the PHP mail() function with HTML content, potential issues can arise with the formatting of the email, such as missing line breaks or incorrect rendering of HTML tags. To solve this issue, you can set additional headers to specify the content type as HTML.

$to = "recipient@example.com";
$subject = "HTML Email Test";
$message = "<h1>This is a test email</h1>";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

mail($to, $subject, $message, $headers);