I have a form in PHP and i am using PHPmailer to sent it to my gmail account. recently i had several problems with messages in hebrew, and i got scrambled messages in my inbox attached example. i now suspect it is an issue of length, but i couldnt find the limit or the reason for the limit. **ONly the hebrew gets scramled! english remains the same.
<?php
error_reporting(0);
require_once('phpmailer/class.phpmailer.php');
$email = 'myname@gmail.com';
$subject = 'New Point Added';
$from = "autosender@mywebsite";
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="iso-8859-1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php if(isset($_POST['submit'])){
$msg = "שם המטייל/ת:<br> ".$_POST['hiker']."<br />";
$msg .= "מדינה: <br>".$_POST['country']."<br />";
$msg .= "חודש ושנה:<br> ".$_POST['dob']."<br />";
$msg .= "סוג:<br> ".$_POST['point']."<br />";
$msg .= "שם המקום:<br> ".$_POST['place']."<br />";
$msg .= "תיאור:<br> ".$_POST['description']."<br />";
$msg .= "מחיר:<br> ".$_POST['price']."<br />";
$msg .= "איך להגיע:<br> ".$_POST['howtoget']."<br />";
$msg .= "חוויות אישיות:<br> ".$_POST['personalexp']."<br />";
$msg .= "מיקום במפה:<br> ".$_POST['latitude']."";
$msg .= ",".$_POST['longitude']."<br />";
$headers = "From: $from" . "";
$headers .= "MIME-Version: 1.0" . "";
$headers .= "Content-type: text/plain; charset=ISO-8859-1";
$mail = new PHPMailer();
$mail->From = $from;
$mail->FromName = $from;
$mail->Subject = $subject;
$mail->Body = $msg;
$mail->AddAddress($email);
$mail->IsHTML(true);
$mail->headers = $headers;
if(isset($_FILES['file'])){
$file_to_attach = $_FILES["file"]["tmp_name"];
$mail->AddAttachment($file_to_attach , $_POST['hiker'].'-'.date('U').'-'.basename($_FILES["file"]["name"]));
}
$mail->Send();
//mail($email,$subject,$msg,$headers);
?>
Well Hebrew will definitely not work in ISO-8859-1, and the text you're putting in there will be corrupted, just as you're seeing. PHPMailer defaults to ISO-8859-1, and you must tell it if you're using something else. Use UTF-8, and make sure that the data you're passing in is actually UTF-8, and not some other Hebrew charset, like ISO-8859-8. Use UTF-8 as the charset in your HTML, and set PHPMailer to use UTF-8 as its charset too, like this:
<meta charset="utf-8">
and
$mail->CharSet = 'UTF-8';