What are the best practices for specifying encoding in the header when using PHP Mail function?

When sending emails using the PHP Mail function, it is important to specify the encoding in the header to ensure that special characters are displayed correctly in the recipient's email client. The recommended encoding for emails is UTF-8, which supports a wide range of characters. To specify the encoding in the header, you can use the "Content-Type" header with the "charset" parameter set to UTF-8.

// Set the email content type and encoding
$headers = 'Content-Type: text/html; charset=UTF-8' . "\r\n";

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