What are best practices for setting up the "From" address in PHP email headers?

When setting up the "From" address in PHP email headers, it is important to use a valid email address that belongs to the domain from which the email is being sent. This helps prevent the email from being flagged as spam by email providers. It is also recommended to use a clear and recognizable sender name along with the email address.

$from_email = 'sender@example.com';
$from_name = 'Sender Name';

$headers = "From: $from_name <$from_email>\r\n";
$headers .= "Reply-To: $from_email\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

// Additional headers and email sending code here