What are some best practices for setting the sender address in PHP emails to avoid displaying the Google address?

When sending emails using PHP, it is important to set the sender address correctly to avoid displaying the Google address. One way to do this is by setting the "From" header in the email headers to a valid email address that you have control over. By doing this, the email will appear to be sent from the address you specify rather than the default Google address.

$to = "recipient@example.com";
$subject = "Subject of the email";
$message = "This is the body of the email.";

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

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