Get the App
SLTechnology News&Howtos  ›  Development  › 

How to solve the problem of Chinese garbled code in phpmailer

Shulou Source: shulou.com Published: 2022-06-03 15:47:10 11月14日 Update

This article introduces the relevant knowledge of "how to solve Chinese garbled codes in phpmailer". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1: open the phpmailer core file class.phpmailer.php, and change public $CharSet = 'iso-8859-1' to public $CharSet = 'UTF-8'

As for why to change 'iso-8859-1' to 'UTF-8', please google or Baidu' iso-8859-1'is clear.

2: set the encoding of the message

The copy code is as follows:

$mail = new PHPMailer ()

$mail- > Charset='UTF-8'

I believe many friends are set to "GBK" or "GB2312". At first, I also did. Later, I learned that Mail is internationalized. If you want to display Chinese correctly in international mailboxes like Gmail, please set the code to "UTF-8".

This is the end of the content of "how to solve Chinese garbled in phpmailer". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Chinese garbled code content international more knowledge coding practical clear successful learning next dilemma reality situation documents articles friends core cases Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno NVidia Redmi Shulou Information Xiaomi