我們曾經在前面一些文章中具體介紹了
下面這段代碼就是PHP發送郵件亂碼的具體解決方法的示例:
- < ?php
- #email.php 2009-11-04
- $name = $_POST['name'];
- $mail = $_POST['mail'];
- $content = $_POST['content'];
- $subject = '測試專用';
- $subject = "=?UTF-8?B?".
base64_encode($subject)."?="; - $body = "來自:$mailn姓名:
$namenn內容:$content"; - $headers = "MIME-Version: 1.0rn";
- $headers .= 'Content-type:
text/html; charset=utf-8' . "rn"; - $headers .= "Content-
Transfer-Encoding: 8bitrn"; - if(mail('*****@qq.com',
$subject,$body,$header)){ - echo 'success';
- }else{
- echo 'fail';
- }
- ?>
希望同構對這段代碼的了解,大家能避免PHP發送郵件亂碼這種情況的出現。