What role does the email header play in determining the character encoding for PHP emails?

The email header plays a crucial role in determining the character encoding for PHP emails. To ensure that the correct character encoding is used, it is important to set the appropriate content-type header in the email header. This header specifies the character encoding to be used for the email content.

// Set the email headers
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

// Additional headers
$headers .= 'From: Your Name <your_email@example.com>' . "\r\n";

// Send the email
mail($to, $subject, $message, $headers);