What are the best practices for handling special characters in PHP when sending emails?

Special characters in email content can cause encoding issues if not handled properly. To ensure that special characters are correctly displayed in emails sent from PHP, it is recommended to use UTF-8 encoding and properly escape any special characters using functions like `htmlspecialchars()`.

// Set the content type and charset for the email
$headers = "Content-type: text/plain; charset=UTF-8\r\n";

// Escape special characters in the email body
$email_body = htmlspecialchars($email_body, ENT_QUOTES, 'UTF-8');

// Send the email with the updated content
mail($to, $subject, $email_body, $headers);