Jump to content

php mail gibberish


golla

Recommended Posts

Hello,

 

im using this code to send mail from my site, but all the emails i get are in gibberish...what i need to change in the code to fix this ? (i need hebrew)

 

this is the code:

 

<?php 
if ($_POST["email"]<>'') { 
$ToEmail = '[email protected]'; 
$EmailSubject = 'הזמנת שולחן?'; 
$mailheader = "From: ".$_POST["[email protected]"]."\r\n"; 
$mailheader .= "Reply-To: ".$_POST["[email protected]"]."\r\n"; 
$mailheader .= "Content-type: text/html; charset=utf-8\r\n"; 
$MESSAGE_BODY = "Name: ".$_POST["name"]." "; 
$MESSAGE_BODY .= "Email: ".$_POST["email"]." "; 
$MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"])." "; 
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); 
?> 
Your message was sent
<?php 
} else { 
?> 
<form action="sendmail.php" method="post">
<table width="400" border="0" cellspacing="2" cellpadding="0">
<tr>
<td width="29%" class="bodytext">Your name:</td>
<td width="71%"><input name="name" type="text" id="name" size="32"></td>
</tr>
<tr>
<td class="bodytext">Email address:</td>
<td><input name="email" type="text" id="email" size="32"></td>
</tr>
<tr>
<td class="bodytext">Comment:</td>
<td><textarea name="comment" cols="45" rows="6" id="comment" class="bodytext"></textarea></td>
</tr>
<tr>
<td class="bodytext"> </td>
<td align="left" valign="top"><input type="submit" name="Submit" value="Send"></td>
</tr>
</table>
</form> 
<?php 
}; 
?>

Link to comment
https://forums.phpfreaks.com/topic/268055-php-mail-gibberish/
Share on other sites

You need to supply us with more information, I'm afraid. "Is gibberish" doesn't tell us a whole lot, other than the problem is probably related to encoding issues. However, not knowing exactly how the data looks before and after sending the e-mail, we cannot give you any specific help on this. Also, verify that your site is being sent as UTF-8, and that the browser does indeed return the user input as UTF-8 as well.

 

However, most importantly you really need to validate the input. As it stands now, this script is open for anyone to abuse in order to send lots and lots of spam-mails to anyone they want. Making it look like its you (or rather your site) that is spamming them.

Link to comment
https://forums.phpfreaks.com/topic/268055-php-mail-gibberish/#findComment-1375871
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.