How does adherence to RFC 822 standards affect the display of header information in HTML emails created with PHP?

Adherence to RFC 822 standards ensures that header information in HTML emails created with PHP is formatted correctly and displays properly in email clients. To ensure compliance, make sure to correctly format headers, including the From, To, Subject, and Content-Type headers. Failure to adhere to these standards may result in emails not being delivered or displaying incorrectly.

// Example of correctly formatting headers in PHP for HTML emails
$to = "recipient@example.com";
$subject = "Test HTML Email";
$message = "<html><body><h1>Hello, World!</h1></body></html>";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= "From: sender@example.com" . "\r\n";

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