We are using
Generally, this problem occurs because Content-type: text/html; charset = UTF-8 is missing in the header parameter of the mail () function, or charset is not UTF-8. Many PHP programs outside China are not considered in Chinese at the beginning of development, so PHP mail () function garbled characters will appear when using Chinese.
Use the base64_encode () function to encode the data using MIME base64.
The header string is prefixed with the encoding type, for example: =? UTF-8? B?
Of course, if it is gb2312, then =? GB2312? B?
The title string is followed :? =
The following is an example of how to handle garbled PHP mail () functions:
- $ To = 'xinple @ example.com ';
- $ Subject = "=? UTF-8? B? ".
Base64_encode ('email title ')."? = ";
- $ Headers = 'mime-Version: 100'. "rn ";
- $ Headers. = 'content-type:
Text/html; charset = UTF-8 '. "rn ";
- // Additional headers
- $ Headers. = 'To: Xinple & lt;
<A href = "mailto: xinple@example.com">
Xinple@example.com </a> & gt; '. "rn ";
- $ Headers. = 'from: Admin & lt;
<A href = "mailto: admin@example.com">
Admin@example.com </a> & gt; '. "rn ";
- $ Headers. = 'reply-To: Xinple & lt; xinple @ example & gt; '. "rn ";
- Mail ($ to, $ subject, $ message, $ headers );
The above is the specific solution for PHP mail () function garbled code, hope to help friends in need.