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)
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.
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"; } ?>
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.
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 );
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With