What are some common methods for handling special characters like ä,ö,ü,ß in PHP when sending text emails?

Special characters like ä,ö,ü,ß can cause encoding issues when sending text emails in PHP. To handle these special characters properly, you can use the mb_encode_mimeheader function to encode the subject line of the email with the appropriate character set.

// Set the subject line with special characters encoded
$subject = 'Subject with special characters ä,ö,ü,ß';
$subject_encoded = mb_encode_mimeheader($subject, 'UTF-8');

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