Is using html_entity_decode() the best approach to handle special characters in PHP emails?
When sending emails in PHP, special characters like accents or symbols may not display correctly in the recipient's inbox. One way to handle this is by using the `html_entity_decode()` function to convert HTML entities back to their corresponding characters before sending the email.
// Example PHP code snippet to handle special characters in emails
$subject = "Subject with special characters é";
$body = "Body with special characters &";
$headers = "From: sender@example.com\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
$subject = html_entity_decode($subject, ENT_QUOTES, 'UTF-8');
$body = html_entity_decode($body, ENT_QUOTES, 'UTF-8');
// Send email
mail('recipient@example.com', $subject, $body, $headers);