How can one ensure that unwanted headers are not included when sending emails using PHP?

To ensure that unwanted headers are not included when sending emails using PHP, you can use the `mb_encode_mimeheader()` function to encode the subject header. This function will properly encode the subject line and prevent additional headers from being injected.

$to = "recipient@example.com";
$subject = "Subject line";
$message = "Email content";

$subject = mb_encode_mimeheader($subject, "UTF-8");

$headers = "From: sender@example.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=UTF-8\r\n";

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