What considerations should be made when defining the header content for PHP mail function to ensure proper email formatting?

When defining the header content for the PHP mail function, it is important to ensure proper email formatting by including necessary headers such as "From", "Reply-To", and "Content-Type". These headers help to specify the sender of the email, provide a reply address, and define the content type of the email (e.g., text/plain or text/html). Failure to include these headers may result in emails being marked as spam or not displaying correctly in the recipient's inbox.

$to = "recipient@example.com";
$subject = "Test Email";
$message = "This is a test email.";
$headers = "From: sender@example.com\r\n";
$headers .= "Reply-To: reply@example.com\r\n";
$headers .= "Content-Type: text/plain; charset=ISO-8859-1\r\n";

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