Search code examples
phpemailcharacter-encodingemail-headers

Sending Hebrew subject in php mail goes Klingon...?


I'm trying to send email with hebrew content/subject like so:

$to = 'email@email.com';
$subject = "איזה יום יפה היום"; 
$message = 'ממש יום יפה';

$headers = 'From: email@email.com' . "\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to, $subject, $message, $headers);

But what I get in the subject is more Klingon than modern Hebrew. The message itself comes out fine, it's just the subject that's all messed up.

What can I do? (I'm open to any hacks you got)


Solution

  • The Content-Type does only describe the message content but not the header. You need to apply the encoded-word encoding on the Subject value. See my answer on PHP email header subject encoding problem for further information.