PHPMailer encoding not received

Hi,

I have below PHP to send HTML formatted email using PHPMailer. The output of the $body is 100% correct and using the RTL as well as the assigned font when I echo on the screen but when the email is sent it does no’t come in RTL nor in the google font assigned.

I have set the Charset to urf-8 alrready.

here is the code:

// send email confirmation to sender;
$body = "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='ar' dir='rtl'>";
$body .= "<head>";
$body .= "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />";
$body .= "<title>Nasser Bin Hamad Al Khalifa</title>";
$body .= "<link href='https://fonts.googleapis.com/css?family=Harmattan' rel='stylesheet' />";
$body .= "</head>";
$body .= "<body dir='rtl'>";
$body .= "<p style='direction: rtl; font-size: large; font-family: Harmattan, sans-serif;'>هذه الرسالة تم إرسالها تلقائيا بواسطة الحاسب الآلي لذا يرجى عدم الرد</p><hr /><br />";
$body .= "<p style='direction: rtl; font-size: large; font-family: Harmattan, sans-serif;'>السلام عليكم ورحمة الله</p><br />";
$body .= "<p style='direction: rtl; font-size: large; font-family: Harmattan, sans-serif;'>شكرا.. لفد تم استلام رسالتك وسنقوم بالرد عليها في أقرب وقت ولكن نظرا للعدد الكبير من الرسائل التي تصلنا فإنه لا يمكننا تحديد وقت محدد للرد.</p>";
$body .= "<br /><br />";
$body .= "<p style='direction: rtl; font-size: large; font-family: Harmattan, sans-serif;'>شكرا لكم..</p>";
$body .= "<br />";
$body .= "<p style='direction: rtl; font-size: large; font-family: Harmattan, sans-serif;'>" . $office_name . "</p>";
$body .= "<p style='direction: rtl; font-size: large; font-family: Harmattan, sans-serif;'>" . $office_name_2nd_line . "</p>";
$body .= "<br /><br />";
$body .= "<a href='http://www.nasseralkhalifa.bh/' target='_blank'>www.nasseralkhalifa.bh</a>";
$body .= "<br /><br />";
$body .= "</body>";
$body .= "</html>";
$body = nl2br($body);
	
//Create a new PHPMailer instance
$mail = new PHPMailer();
$mail->CharSet = 'UTF-8';
//Tell PHPMailer to use SMTP
$mail->IsSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug  = 0;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host       = "mail.myhost.com";
// $mail->SMTPSecure = 'tls';
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port       = 587;
//Whether to use SMTP authentication
$mail->SMTPAuth   = true;
//Username to use for SMTP authentication
$mail->Username   = "noreply@domain.com";
//Password to use for SMTP authentication
$mail->Password   = "My@Password";
//Set who the message is to be sent from
$mail->SetFrom("noreply@domain.com", $office_name);
//Set an alternative reply-to address
// $mail->AddReplyTo($_POST['txtEmail'], $_POST['txtName']);
//Set who the message is to be sent to
$mail->AddAddress($email, $full_name);
		
//Set the subject line
$mail->Subject = "شكرا.. تم استلام رسالتك";
		
//Read an HTML message body from an external file, convert referenced images to embedded, convert HTML into a basic plain-text alternative body
// $mail->MsgHTML($body);
$mail->Body = $body;
$mail->IsHTML(true);
		
if (!$mail->send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
}

Thanks,
Jassim

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.