Solve Chinese garbled characters in phpmailer emails

Source: Internet
Author: User
Phpmailer & nbsp; is very powerful. it allows new PHP users to send emails in complex socket mode with simple configuration. However, phpmailer is written by foreigners, chinese garbled characters are not accidental. The following is my summary over the past few days to solve the problem of Chinese garbled characters in phpmailer sending. 1: Open phpmailer & nbsp; core file & nbsp; class.

Phpmailer? Very powerful. it allows new PHP users to send emails in complicated socket mode under simple configuration,

However, phpmailer is written by foreigners and Chinese garbled characters are not accidental.

The following is my summary over the past few days to solve the problem of Chinese garbled characters in phpmailer sending.

1: Open phpmailer? Core files? Class. phpmailer. php ?,? Yes? Public? $ CharSet? =? 'ISO-8859-1 ';??? Change? Public? $ CharSet? =? 'Utf-8 ';

$ Mail? =? New? PHPMailer ();

2: Set the email encoding;

$ 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 what is the title encoding ...? If you have tested multiple kinds of mailboxes, you will find that the title is garbled in Chinese. that's right, even if you set it? $ Mail-> Charset = "UTF-8 ";

In this way, the Chinese garbled characters of the title will be solved.

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.