What are some best practices for setting up the "From" and "Reply-To" headers when sending emails via PHP?

When sending emails via PHP, it is important to properly set up the "From" and "Reply-To" headers to ensure that the email is delivered correctly and can be replied to by the recipient. The "From" header should contain a valid email address, while the "Reply-To" header can be used to specify a different email address for replies.

$to = "recipient@example.com";
$subject = "Test Email";
$message = "This is a test email.";

$headers = "From: sender@example.com\r\n";
$headers .= "Reply-To: replyto@example.com\r\n";

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