PHP function mail () garbled solution introduction. Some people often encounter some problems when using PHP for programming operations. For example, if you use the PHP function mail () to solve garbled code, use base64_encode () to use MIMEba. some people often encounter some problems when using PHP for programming. For example
PHP function mail () garbled
Solution:
First use the function base64_encode ()-encode the data using MIME base64
The header string is prefixed with the encoding type, for example: =? UTF-8? B?
The title string is followed :? =
Content-type-prevents garbled text in the email header. example:
- $ To = 'name @ example.com ';
-
- $ Subject = "=? UTF-8? B ?". Base64_encode ('email title ')."? = ";
-
- $ Headers = 'Mime-Version: 1.0 '. "rn ";
-
- $ Headers. = 'content-type: text/html; charset = utf-8 '. "rn ";
-
- // Additional headers
-
- $ Headers. = 'To: Name <name@example.com>'. "rn ";
-
- $ Headers. = 'From: Admin <admin@example.com>'. "rn ";
-
- $ Headers. = 'reply-To: Name <name@example.com> '. "rn ";
-
- Mail ($ to, $ subject, $ message, $ headers );
-
The above is the specific solution for garbled characters in PHP function mail.
Bytes. For example, the solution for garbled characters in mail () using the PHP function is to use base64_encode () to use MIME ba...