What are the risks of sending emails with PHP in terms of revealing sender information?

When sending emails with PHP, the sender's information can be easily revealed if the "From" header is not properly set. To prevent this, always set the "From" header to a valid email address that you control. This will ensure that the recipient sees the email as coming from the specified address, rather than potentially exposing sensitive information about the server or sender.

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

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