5

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)

Gilles 'SO- stop being evil'
  • 104,111
  • 38
  • 209
  • 254
Gal
  • 23,122
  • 32
  • 97
  • 118
  • Somewhere along the way, your character encoding has become seriously messed up. As far as I know, ISO-8859-1 doesn't even have any Hebrew characters in it! – Quentin Dec 20 '10 at 14:19
  • @David the message comes out ok, the problem is with the subject... – Gal Dec 20 '10 at 14:22
  • Related question: http://stackoverflow.com/questions/4389676/php-email-header-subject-encoding-problem – Gumbo Dec 20 '10 at 14:23

1 Answers1

6

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.

Community
  • 1
  • 1
Gumbo
  • 643,351
  • 109
  • 780
  • 844