PHP mail () function garbled specific solution _php Tutorial

Source: Internet
Author: User
We are using

In general, this problem occurs because the mail () function's header parameter is less content-type:text/html; Charset=utf-8, or CharSet is not utf-8. A lot of foreign PHP program at the beginning of the development of the time did not have it in Chinese, so when the use of Chinese will appear in PHP mail () function garbled.

Use the function Base64_encode () to encode the data using the MIME base64
The title string is pre-encoded type such as: =? UTF-8? B?
Of course, if it's gb2312. GB2312? B?
Title string after add:? =

PHP mail () function garbled processing methods such as the following examples

 
 
  1. $ to = ' xinple@example.com ' ;
  2. $ subject = "=? UTF-8? B? " .
    Base64_encode (' mail header '). "? =";
  3. $ Headers = ' mime-version:1.0 ' . "RN";
  4. $headers . = ' Content-type:
    text/html; Charset=utf-8 ' . "RN";
  5. Additional headers
  6. $headers . = ' To:xinple <
    < a href= "mailto:xinple@example.com" >
    Xinple@example.com> ' . "RN";
  7. $headers . = ' From:admin <

    Admin@example.com> ' . "RN";
  8. $headers . = ' Reply-to:xinple <xinple@example> ' . "RN";
  9. Mail ($to, $subject, $message, $headers);

The above is the PHP mail () function garbled details of the specific approach, I hope to have the necessary friends to help.


http://www.bkjia.com/PHPjc/446193.html www.bkjia.com true http://www.bkjia.com/PHPjc/446193.html techarticle The reason we use this problem is that the mail () function has less content-type:text/html in the header parameter, Charset=utf-8, or CharSet is not utf-8. A lot of foreign PHP process ...

  • 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.