search
Homephp教程php手册PHP发送邮件乱码的具体解决方法

PHP发送邮件乱码的具体解决方法

Jun 13, 2016 am 11:08 AM
phpunderGarbled characterscodespecificsendusarticlemethodofsolvemail

我们曾经在前面一些文章中具体介绍了

下面这段代码就是PHP发送邮件乱码的具体解决方法的示例:

  1.  ?php 
  2. #email.php 2009-11-04  
  3. $name = $_POST['name'];  
  4. $mail = $_POST['mail'];  
  5. $content = $_POST['content'];  
  6. $subject = '测试专用';  
  7. $subject = "=?UTF-8?B?".
    base64_encode($subject)."?=";  
  8. $body = "来自:$mailn姓名:
    $namenn内容:$content"
    ;  
  9. $headers = "MIME-Version: 1.0rn";  
  10. $headers .'Content-type: 
    text/html; charset=utf-8'
     . "rn";  
  11. $headers ."Content-
    Transfer-Encoding: 8bitrn"
    ;  
  12. if(mail('*****@qq.com',
    $subject,$body,$header)){  
  13. echo 'success';  
  14. }else{  
  15. echo 'fail';   
  16. }  
  17. ?> 

希望同构对这段代码的了解,大家能避免PHP发送邮件乱码这种情况的出现。


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)