What potential pitfalls should be considered when sending text emails with special characters in PHP?

When sending text emails with special characters in PHP, potential pitfalls to consider include encoding issues that may cause the special characters to display incorrectly in the recipient's email client. To avoid this, it is important to properly encode the email content using UTF-8 encoding to ensure compatibility across different email clients.

// Set the content type and charset for the email
$headers = 'Content-type: text/html; charset=UTF-8';

// Encode the email content using UTF-8
$email_content = mb_convert_encoding($email_content, 'UTF-8', 'auto');

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