golla Posted September 6, 2012 Share Posted September 6, 2012 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 = 'info@info.co.il'; $EmailSubject = 'הזמנת שולחן?'; $mailheader = "From: ".$_POST["contact@blabla.co.il"]."\r\n"; $mailheader .= "Reply-To: ".$_POST["contact@blabla.co.il"]."\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 }; ?> Quote Link to comment https://forums.phpfreaks.com/topic/268055-php-mail-gibberish/ Share on other sites More sharing options...
gristoi Posted September 6, 2012 Share Posted September 6, 2012 change the charset to: charset=windows-1255 Quote Link to comment https://forums.phpfreaks.com/topic/268055-php-mail-gibberish/#findComment-1375711 Share on other sites More sharing options...
Christian F. Posted September 6, 2012 Share Posted September 6, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/268055-php-mail-gibberish/#findComment-1375871 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.