Help with Mail Function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Shren
Forum Newbie
Posts: 1
Joined: Mon Jul 20, 2009 8:00 am

Help with Mail Function

Post by Shren »

Hello everybody, I have been looking for ages for some help
I have this PHP file that gets info from a HTML form in my website and then send that info to my mail. ( Contact Form )
the thing is that my site is in Hebrew and the info that the client is inserting to the form is in Hebrew. the problem is when i get the mail its in Jibrish....

I have tried all encoding possible,
Mayb someone here can solve this problem for me.
I have to mantion that the host fully support Hebrew and RTL lang.

the code:

Code: Select all

<?php
ini_set("SMTP","******");
ini_set("UserName","*******");
ini_set("Password","****");
$subject = "New Message From *****";
$myMail = "bla@inc.com";
 
$sentFrom = $_REQUEST['mail'];
$senderName = $_REQUEST['name'];
$senderPhone = $_REQUEST['phone'];
$content = $_REQUEST['comments'];
$headers = "From: $sentFrom\r\n";
$headers .= "MIME-Version: 3.1\r\n";
$headers .= "Content-languege: hw\r\n";
$headers .= "Content-type: text/html; charset=utf-8"; //* I have tried Hebrew Window charset doesnt work *//
 
$emailbody =<<<EOD
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/> //* same as above *//
<meta http-equiv="Content-language" content="he"/>
<body>
?? ?????:$senderName <br><hr>
???? ?????: $senderPhone <br>
<hr><br>
???? ??????: <br>
$content <br>
EOD;
$success = @mail($myMail, $subject, $emailbody, $headers);
echo $success ? "Mail Sent" : "Mail Failed";
?>
 
<html>
<head>
<script langauge=Javascript>
    //window.close();
</script>
</head>
<body>
<Br><Br><Br><Br><Br><Br>
<center>
<h2><font color=#22A2A5>?????? ????? ??????.</font></h2>
<br>
<A onMouseOver="this.style.cursor='hand';"><h4 onClick="window.close();">???? ????.</h4></a>
</center>
</body>
</html>
If someone has an idea about why am I getting Jibrish instead of Hebrew please feel free to advice me
Thanks in advance
Ran.
Randwulf
Forum Commoner
Posts: 63
Joined: Wed Jan 07, 2009 7:07 am

Re: Help with Mail Function

Post by Randwulf »

I had a similar problem once, and the way I fixed it may not be practical to you, but it will at least give you some insight into why there's a problem.

I was trying to move files from one site to another using PHP. These files often had non-standard characters, such as 1char ellipses, a different type of quotation marks, and some other ones that PHP turned to gibberish when it saved. What I ended up having to do was make the PHP script convert each non-standard character to a standard one. For some reason PHP seems to be able to hold non-standard characters in memory, but once it tries to put those characters somewhere (in an HTML file in my case) it turns them into gibberish. Here are a few lines from the script I'm talking about:

Code: Select all

 
$trimmedStory = str_replace("’", "'", $trimmedStory);
$trimmedStory = str_replace("“",'"',$trimmedStory);
$trimmedStory = str_replace("…","...",$trimmedStory);
$trimmedStory = str_replace('”','"',$trimmedStory);
 
I hope that helps.
Post Reply