I am using php mailer at my website contact form. When i receive a message in greek language, i don't receive the text as typed in the contact form. In class.phpmailer.php file line 59 the encoding is public $CharSet = 'iso-8859-1';
Is there a way to make my text appear correctly as typed in the contact form?
Languages comonly supported by ISO/IEC 8859-1 can be found here
I have also tried german and albanian languages but i also have the same problem. I can only receive english, if the user types another language on some words i receive "chinese".
The code:
<?php
require_once('phpmailer/class.phpmailer.php');
// if(isset($_POST['g-recaptcha-response'])){
if (empty($_POST['Email'])) {
$_POST['Email'] = "-";
}
if (empty($_POST['Name'])) {
$_POST['Name'] = "-";
}
if (empty($_POST['Subject'])) {
$_POST['Subject'] = " ";
}
if (empty($_POST['message'])) {
$_POST['message'] = "-";
}
$mymail = smtpmailer("example@gmail.com", $_POST['Email'], $_POST['Name'],
$_POST['Subject'], $_POST['message']);
function smtpmailer($to, $from, $from_name, $subject, $body)
{
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Debugoutput = 'html';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = 'example@gmail.com';
$mail->Password = 'pass';
$mail->SetFrom($from, $from_name);
$mail->Subject = " Contact form ~Name: $from_name ~ subject: $subject ";
$mail->Body = " You have received a new message
from $from_name, here are the details:
_____
___________________
" . "
Dear $from_name,
Your enquiry had been received on " . date("D j F ") . "
INFORMATION SUBMITTED: " . "
Name: $from_name
Email: $from
Subject: $subject
Message: $body
To:
$to
Date: " . date("d/m/y") . "
Website: " . "
____________
__________________"; //end body
$mail->AddAddress($to);
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Well done $from_name, your message has been sent!
We will reply to the following email: $from" . "
Your Message: $body";
}
} //end function smtpmailer
//}
?>