简体   繁体   中英

PHP mailer Character encoding issue

I m facing some character encoding issues like this:

D\\\'Huison-Longueville Référence 

Original Text was :

D'Huison-Longueville Référence 

Here is my PHP Mailer script:

                 $mail = new PHPMailer();
                 $mail->CharSet = 'UTF-8';
                 $mail->IsMail();
                 $mail->Subject = $subject;
                 $mail->IsHTML(true);
                 $mail->Body = $email_body;
                 $mail->From='support@xyz.com';
                 $mail->FromName= "Support Team";
                 $mail->AddAddress($toEmail);
                 $mail->Send();

I had the same problem. The charset was not being changed although I was specifying the new one like you with:

$mail->CharSet = 'UTF-8';

Since you use "IsMail" you have to go to the folder where class.phpmailer.php resides (generally in the same folder as the main phpmailer.php file) and edit it. There you will see the default values for the mail and you will see that it is set to "ISO-8859-1".

Change

public $CharSet = 'ISO-8859-1';

to

public $CharSet = 'UTF-8';

Change it to "UTF-8" or any other charset you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM