I've created a 'contact us' form using the php code below : <?php $sender = $_REQUEST['sender'] ; $subject = $_REQUEST['subject'] ; $message = $_REQUEST['message'] ; $mail = $_REQUEST['mail'] ; $phone = $_REQUEST['phone'] ; $totalmessage = " Name: $sender \n Subject: $subject \n Message: $message \n Email: $mail \n Phone: $phone \n"; mail( "my@mail.com", "Website", $totalmessage, "From: $email" ); echo "<img src=\"mail.gif\" title=\"Success\" alt=\"Success\" />"; ?> PHP: It works. the problem is that when the user input hebrew letters to the form, i can't see it correctly. Also, the "Name, Subject, Message" etc. should be in hebrew and i wrote it in english just for you so you'll be able to understand the code. I read lots of tutorials about encoding using $headers, but i couldn't implement it to the code. i really need your help on this. Thanks.
Send message in UTF-8 enconding. Use headers, something like this: $headers .= "From: $email\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/plain; charset=utf-8\r\n"; $headers .= "Content-Transfer-Encoding: quoted-printable\r\n"; PHP: And change this part too: mail( "my@mail.com", "Website", $totalmessage, $headers); PHP: Not sure if the syntax is right.
<?php $sender = $_REQUEST['sender'] ; $subject = $_REQUEST['subject'] ; $message = $_REQUEST['message'] ; $mail = $_REQUEST['mail'] ; $phone = $_REQUEST['phone'] ; $totalmessage = " Name: $sender \r\n Subject: $subject \r\n Message: $message \r\n Email: $mail \r\n Phone: $phone \r\n"; $headers .= "From: $mail\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/plain; charset=utf-8\r\n"; $headers .= "Content-Transfer-Encoding: quoted-printable\r\n"; mail( "my@mail.com", "Website", $totalmessage, $headers ); echo "<img src=\"mail.gif\" title=\"Success\" alt=\"Success\" />"; ?> PHP: This is the code now. still doesn't work.
The code doesn't work or the hebrew doesn't show correctly? What kind of encoding does the page has, where is the submit form?
Or maybe it's better to use windows-1255 charset, what is meant for hebrew... <?php header('Content-Type: text/html; charset=windows-1255'); $sender = $_REQUEST['sender'] ; $subject = $_REQUEST['subject'] ; $message = $_REQUEST['message'] ; $mail = $_REQUEST['mail'] ; $phone = $_REQUEST['phone'] ; $totalmessage = " Name: $sender \r\n Subject: $subject \r\n Message: $message \r\n Email: $mail \r\n Phone: $phone \r\n"; $headers .= "From: $mail\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/plain; charset=windows-1255\r\n"; $headers .= "Content-Transfer-Encoding: quoted-printable\r\n"; mail( "my@mail.com", "Website", $totalmessage, $headers ); echo "<img src=\"mail.gif\" title=\"Success\" alt=\"Success\" />"; ?> PHP: Maybe this one works. And if not, then try replacing those to charset windows-1255 with utf-8.
noted that this line $headers .= "Content-Transfer-Encoding: quoted-printable\r\n"; Code (markup): may cause your html mail body to go weird, for example, the body of: "<table width='100'>" will becomes "<table width='>" Edit: Actually I remember you don't even need that line, just try it and see then