This article describes how to solve the phpmailer Chinese garbled problem. For more information, see Section 1: Open the phpmailer core file class. phpmailer. php: Change public $ CharSet = 'ISO-8859-1 'to public $ CharSet = 'utf-8 ′;
If you want to change 'ISO-8859-1 'to 'utf-8', google or Baidu to 'ISO-8859-1.
2: Set the email encoding;
The code is as follows: $ mail = new PHPMailer ();
$ Mail-> Charset = 'utf-8 ′;
I believe many of my friends have been set to "GBK" or "GB2312". I started with it and later learned that Mail is internationalized, if you want to display Chinese properly in an international mailbox like Gmail, set the encoding to "UTF-8 ";
3. set the title encoding;
Someone may ask here that the email encoding is set and the title encoding is set... If you have tested a variety of mailboxes, you will find the title Chinese is garbled, yes, even if you set $ mail-> Charset = "UTF-8 ″;
Now that you are learning php, you should read the php manual or pay attention to php.net. the solution to the title garbled text is the hhtp: // .www.php.net/mailon the php official website.
$ Mail-> Subject = "mail title"; changed to $ mail-> Subject = "=? UTF-8? B ?" . Base64_encode ("letter Title"). "? = ";
"This encoding is designed to enable binary data to be transmitted through a non-pure 8-bit transport layer, such as the subject of an email ." (From php manual base64_encode ())