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 ())