What are best practices for ensuring that HTML content is displayed correctly in emails sent through PHP?

When sending HTML content in emails through PHP, it is important to set the appropriate headers and ensure that the HTML content is properly formatted. To ensure that the HTML content is displayed correctly, it is recommended to use the `Content-Type` header with the value `text/html` and properly encode any special characters.

<?php
$to = 'recipient@example.com';
$subject = 'HTML Email Test';
$message = '<html><body><h1>Hello, World!</h1><p>This is a test email with HTML content.</p></body></html>';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

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