Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

$to = '[email protected]';
$subject = "איזה יום יפה היום"; 
$message = 'ממש יום יפה';

$headers = 'From: [email protected]' . "\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)

like image 401
Gal Avatar asked Dec 20 '10 14:12

Gal


People also ask

Why my mail function is not working in PHP?

If it's still not working: change the sender ($sender) to a local email (use the same email as used for recipient). Upload the modified php file and retry. Contact your provider if it still does not work. Tell your provider that the standard php "mail()" function returns TRUE, but not mail will be sent.

How do you check PHP mail () is working?

to check if it is sending mail as intended; <? php $email = "[email protected]"; $subject = "Email Test"; $message = "this is a mail testing email function on server"; $sendMail = mail($email, $subject, $message); if($sendMail) { echo "Email Sent Successfully"; } else { echo "Mail Failed"; } ?>

How do I stop emails going to spam in Phpmailer?

Make sure that the domain you send mails from are using the same IP address as when you do a reverse lookup of that IP address, best to use a subdomain like “mail” for this particular use case. example: mail.mydomain.com with IP 123.123. 123.123 and in a reverse lookup 123.123.

How can you send email in PHP?

PHP makes use of mail() function to send an email. This function requires three mandatory arguments that specify the recipient's email address, the subject of the the message and the actual message additionally there are other two optional parameters. mail( to, subject, message, headers, parameters );


1 Answers

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.

like image 169
Gumbo Avatar answered Sep 23 '22 05:09

Gumbo