What are best practices for constructing headers when sending emails with PHP?

When sending emails with PHP, it is important to construct headers properly to ensure the email is delivered correctly and not marked as spam. Best practices include setting headers such as "From", "Reply-To", "Content-Type", and "MIME-Version" to provide necessary information to the email client.

// Set email headers
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Your Name <your_email@example.com>' . "\r\n";
$headers .= 'Reply-To: Reply Email <reply_email@example.com>' . "\r\n";

// Send email
$to = 'recipient@example.com';
$subject = 'Subject of the email';
$message = 'Content of the email';

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