What are common issues when sending HTML code via PHP email?

Common issues when sending HTML code via PHP email include the HTML code not rendering correctly in the recipient's email client, the email being marked as spam due to improper formatting, and images not displaying properly. To solve these issues, ensure that the HTML code is well-formed, use inline CSS styles instead of external stylesheets, and reference images using absolute URLs.

<?php
$to = 'recipient@example.com';
$subject = 'HTML Email Test';
$message = '
<html>
<head>
<title>HTML Email</title>
</head>
<body>
<h1>Hello, this is a test email!</h1>
<p>This is some <strong>HTML</strong> content.</p>
<img src="https://example.com/image.jpg" alt="Image">
</body>
</html>
';

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

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