PHP function mail () garbled solution _ PHP Tutorial

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

 
 
  1. $ To = 'name @ example.com ';
  2. $ Subject = "=? UTF-8? B ?". Base64_encode ('email title ')."? = ";
  3. $ Headers = 'Mime-Version: 1.0 '. "rn ";
  4. $ Headers. = 'content-type: text/html; charset = utf-8 '. "rn ";
  5. // Additional headers
  6. $ Headers. = 'To: Name <name@example.com>'. "rn ";
  7. $ Headers. = 'From: Admin <admin@example.com>'. "rn ";
  8. $ Headers. = 'reply-To: Name <name@example.com> '. "rn ";
  9. 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...

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.