What are common pitfalls when handling special characters like umlauts in PHP email forms?

When handling special characters like umlauts in PHP email forms, a common pitfall is not properly encoding the characters before sending the email. To solve this issue, use the mb_encode_mimeheader() function to encode the subject line of the email with UTF-8 encoding.

$subject = 'Subject with ümläuts';
$subject_encoded = mb_encode_mimeheader($subject, 'UTF-8');

// Send email with encoded subject
mail('recipient@example.com', $subject_encoded, 'Message body', 'From: sender@example.com');