Phpmailer Chinese garbled problem solution _ php instance

Source: Internet
Author: User
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 ())

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.