How can the missing "From:" header in the email be addressed when using manual SMTP communication in PHP?

When using manual SMTP communication in PHP, the missing "From:" header in the email can be addressed by adding the "From:" header in the email headers before sending the email. This header specifies the email address of the sender.

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

// Send email
if (mail($to, $subject, $message, $headers)) {
    echo "Email sent successfully.";
} else {
    echo "Email sending failed.";
}