How can incorrect line breaks in email headers affect the delivery of HTML emails sent using PHP mail() function?

Incorrect line breaks in email headers can cause the email to be rejected or marked as spam by the recipient's email server. To solve this issue, make sure that each header in the email is properly formatted with \r\n line breaks.

<?php
$to = "recipient@example.com";
$subject = "Test Email";
$message = "<html><body><h1>Hello, World!</h1></body></html>";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: sender@example.com\r\n";

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