我也正想问这个问题,有谁知道啊? 我试过附件显示的是:
PGh0bWwgeG1sbnM6bz0idXJuOnNjaGVtYXMtbWljcm9zb2Z0LWNvbTpvZmZpY2U6b2ZmaWNlIg0K
eG1sbnM6dz0idXJuOnNjaGVtYXMtbWljcm9zb2Z0LWNvbTpvZmZpY2U6d29yZCINCnhtbG5zPSJ
不知为何?

解决方案 »

  1.   

    function getContentType($inFileName){   
    //--去除路径   
    $inFileName = basename($inFileName);   
    //--去除没有扩展名的文件   
    if(strrchr($inFileName, ".") == false){  
     return "application/octet-stream";  
     }  
     //--提取扩展名并进行判断   
    $extension = strrchr($inFileName, ".");   
    switch($extension){   
    case ".gif": return "image/gif";  
    case ".gz": return "application/x-gzip";  
    case ".htm": return "text/html"; 
    case ".html": return "text/html";   
    case ".jpg": return "image/jpeg";   
    case ".tar": return "application/x-tar";   
    case ".txt": return "text/plain";   
    case ".zip": return "application/zip";   
    default: return "application/octet-stream";   
    }   
    return "application/octet-stream";   
    }   
      

  2.   

    to Goal3() 
    PGh0bWwgeG1sbnM6bz0idXJuOnNjaGVtYXMtbWljcm9zb2Z0LWNvbTpvZmZpY2U6b2ZmaWNlIg0K
    eG1sbnM6dz0idXJuOnNjaGVtYXMtbWljcm9zb2Z0LWNvbTpvZmZpY2U6d29yZCINCnhtbG5zPSJ
    是经过base64编码的,用base64_decode()解码后为
    <html xmlns:o="urn:schemas-microsoft-com:office:office"
    xmlns:w="urn:schemas-microsoft-com:office:word"
    xmlns="
      

  3.   

    估计你代码有误
    看看这个
    <?php
    /*
    $to 目标
    $subject 主题
    $message 正文
    $from 发自
    $content_type 类型
    $attache 附件,文件名放在数组中
    */
    function mail2( $to, $subject, $message, $from, $content_type, $attache="") {
      if(!empty($from)) $head = "From: $from\n";
      if(empty($content_type)) $content_type = "text/plain";  if(is_array($attache)) {
        $boundary = "===" . md5(uniqid("")) . "===";
        $head .= "Mime-Version: 1.0\nContent-Type: multipart/mixed; boundary=\"";
        $head .= "$boundary\"\n\nThis is a multi-part message in MIME format.\n\n";
        $head .= "--$boundary\n";
        $head .= "Content-Type: $content_type\n";
        $head .= "\n$message\n\n";    while(list($key, $val) = each($attache)) {
          $fd = fopen("$val", "r") or die("unable to open file $val");
          $contents = chunk_split(base64_encode(fread($fd,filesize("$val"))));
          fclose($fd);
          $head .= "--$boundary\n";
          $head .= "Content-Type: application/octet-stream; name=\"".basename($val);
          $head .= "\"\nContent-Transfer-Encoding: BASE64\n";
          $head .= "Content-Disposition: attachment; filename=\"".basename($val);
          $head .= "\"\n\n" . $contents . "\n\n";
        }
        $head .= "--" . $boundary . "--\n\n";
      }else{
        if(!empty($content_type)) {
          $head .= "Content-Type: $content_type\n";
          $head .= "\n$message\n";
        } 
      }
      return mail($to,$subject,"",$head ); 
    } // Calling sample 
    mail2("[email protected]","Hello",$message,"[email protected]","",array("a.txt","count.txt"));
    ?>
      

  4.   

    估计你代码有误
    看看这个
    <?php
    /*
    $to 目标
    $subject 主题
    $message 正文
    $from 发自
    $content_type 类型
    $attache 附件,文件名放在数组中
    */
    function mail2( $to, $subject, $message, $from, $content_type, $attache="") {
      if(!empty($from)) $head = "From: $from\n";
      if(empty($content_type)) $content_type = "text/plain";  if(is_array($attache)) {
        $boundary = "===" . md5(uniqid("")) . "===";
        $head .= "Mime-Version: 1.0\nContent-Type: multipart/mixed; boundary=\"";
        $head .= "$boundary\"\n\nThis is a multi-part message in MIME format.\n\n";
        $head .= "--$boundary\n";
        $head .= "Content-Type: $content_type\n";
        $head .= "\n$message\n\n";    while(list($key, $val) = each($attache)) {
          $fd = fopen("$val", "r") or die("unable to open file $val");
          $contents = chunk_split(base64_encode(fread($fd,filesize("$val"))));
          fclose($fd);
          $head .= "--$boundary\n";
          $head .= "Content-Type: application/octet-stream; name=\"".basename($val);
          $head .= "\"\nContent-Transfer-Encoding: BASE64\n";
          $head .= "Content-Disposition: attachment; filename=\"".basename($val);
          $head .= "\"\n\n" . $contents . "\n\n";
        }
        $head .= "--" . $boundary . "--\n\n";
      }else{
        if(!empty($content_type)) {
          $head .= "Content-Type: $content_type\n";
          $head .= "\n$message\n";
        } 
      }
      return mail($to,$subject,"",$head ); 
    } // Calling sample 
    mail2("[email protected]","Hello",$message,"[email protected]","",array("a.txt","count.txt"));
    ?>