http://www.phpbuilder.com/columns/kartic20000807.php3仔細讀完, MIME 因該的細節都有說到

解决方案 »

  1.   

    $mailFrom=$mailFrom;
    $mailCC=$mailCC;
    $mailBCC=$mailBCC;
      晕倒……我没有你用的这个类,给个url,我好看看。
      

  2.   

    我把这个类贴给大家吧!请大家研究研究!
    第一部分
    <?
    /*************函数列表***************
        Function Listing:
            setTo($inAddress)
            setCC($inAddress)
            setBCC($inAddress)
            setFrom($inAddress)
            setSubject($inSubject)
            setText($inText)
            setHTML($inHTML)
            setAttachments($inAttachments)
            checkEmail($inAddress)
            loadTemplate($inFileLocation,$inHash,$inFormat)
            getRandomBoundary($offset)
            getContentType()
            formatTextHeader()
            formatHTMLHeader()
            formatAttachmentHeader($inFileLocation)
            send()
    ***********************************************************/class Email
    {
         //---全局变量
        var $mailTo            =  "";      // 邮件目的地数组
        var $mailCC            =  "";      // 抄送人地址
        var $mailBCC           =  "";      // 暗送人地址
        var $mailFrom          =  "";      // 发送人地址
        var $mailSubject       =  "";      // 邮件主题
        var $mailText          =  "";      // 纯文本信息
        var $mailHTML          =  "";      // HTML 文本信息
        var $mailImg           =  "";      //HTML 文件中的图片
        var $mailAttachments   =  "";      // 附件数组/************************设置电子邮件的地址***********************/    function setTo($inAddress){
             //--把逗号作为分割符分离邮件地址
            $addressArray = explode( ",",$inAddress);
             //--检查每一个邮件地址,有错就退出
            for($i=0;$i<count($addressArray);$i++){
                if($this->checkEmail($addressArray[$i])==false) return false;
            }
             //--如果所有的邮件地址都正确,那么调用implode把邮件地址恢复
            $this->mailTo = implode($addressArray, ",");
            return true;
        }
    /******************设置邮件的抄送地址*******************/
        function setCC($inAddress){
             //--用逗号分割邮件地址
            $addressArray = explode( ",",$inAddress);
             //--检查每一个邮件地址,如果有错就退出
            for($i=0;$i<count($addressArray);$i++){
                if($this->checkEmail($addressArray[$i])==false) return false;
            }
             //-- 若过每个邮件地址都正确,用implode把邮件地址恢复
            $this->mailCC = implode($addressArray, ",");
            return true;
        }
    /****************设置邮件的暗送地址**************************/    function setBCC($inAddress){
             //--用逗号分割邮件地址
            $addressArray = explode( ",",$inAddress);
             //--检查每一个邮件地址,如果有错就退出
            for($i=0;$i<count($addressArray);$i++){
                if($this->checkEmail($addressArray[$i])==false) return false;
            }
             //--若过每个邮件地址都正确,用implode把邮件地址恢复
            $this->mailBCC = implode($addressArray, ",");
            return true;
        }
    /**************设置邮件发送人的地址******************/    function setFrom($inAddress){
            if($this->checkEmail($inAddress)){
                $this->mailFrom = $inAddress;
                return true;
            }
            return false;
        }
    /************设置邮件主题******************/    function setSubject($inSubject){
            if(strlen(trim($inSubject)) > 0){
                $this->mailSubject = ereg_replace( "\n", "",$inSubject);
                return true;
            }
            return false;
        }
    /***************设置邮件纯文本内容***************/
        function setText($inText){
            if(strlen(trim($inText)) > 0){
                $this->mailText = $inText;
                return true;
            }
            return false;
        }
    /**********设置邮件的 HTML 文本内容**************/    function setHTML($inHTML){
            if(strlen(trim($inHTML)) > 0){
                $this->mailHTML = $inHTML;
                return true;
            }
            return false;
        }
    /*************设置HTML文本信息中的图片******************/
        function setHtmlImages($images){
            if(strlen(trim($images)) > 0){
                $this->mailImg = $images;
                return true;
            }
            return false;
        }
    /**************存储附件字符串****************/
        function setAttachments($inAttachments){
            if(strlen(trim($inAttachments)) > 0){
                $this->mailAttachments = $inAttachments;
                return true;
            }
            return false;
        }
    /***********检查E-mail地址是否合法**************/    function checkEmail($inAddress){
            return (ereg("^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$",$inAddress));
        }
    /********读取一个模版文件并替换一些宏定义的值********/    function loadTemplate($inFileLocation,$inHash,$inFormat){         //指定模板的一些符号
            $templateDelim =  "~";
            $templateNameStart =  "!";
             //--设定外部字串
            $templateLineOut =  "";
             //--打开模板文件
            if($templateFile = fopen($inFileLocation, "r")){
                 //--循环分析文件,一行一行的分析
                while(!feof($templateFile)){
                     //--get 1000 chars or (line break internal to fgets)
                    $templateLine = fgets($templateFile,1000);
                     //--分开文件的没一行,并把其存入数组中,并规范气语句
                    $templateLineArray = explode($templateDelim,$templateLine);
                     //--检查每一个数组
                    for( $i=0; $i<count($templateLineArray);$i++){
                         //--从0的位置开始寻找$templateNAMEStart
                        if(strcspn($templateLineArray[$i],$templateNameStart)==0){
                             //--在$templateNAMEStart后得到宏定义的名字
                            $hashName = substr($templateLineArray[$i],1);
                             //--替换宏定义的名字
                            $templateLineArray[$i] = ereg_replace($hashName,(string)$inHash[$hashName],$hashName);
                        }
                    }
                     //-- 输出全子串数,并把它加入到外部数组中
                    $templateLineOut .= implode($templateLineArray, "");
                }
                 //--关闭文件
                fclose($templateFile);
                 //--按固定格式设置邮件内容
                if( strtoupper($inFormat)== "TEXT" )
                 return($this->setText($templateLineOut));
                else if( strtoupper($inFormat)== "HTML" )
                 return($this->setHTML($templateLineOut));
            }
            return false;
        }
    /*************返回一个边界随机值************/
        function getRandomBoundary($offset = 0){
             //--随机产生数
            srand(time()+$offset);
             //--return md5 32 bits plus 4 dashes to make 38 chars
            return ( "----".(md5(rand())));
        }
    /***************为文件中类返回一个内容种类************/    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  ".php":    return  "text/html";
                case  ".shtml":  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";
        }
    /**********为文件返回一个格式化的头信息*************/ function formatTextHeader(){
            $outTextHeader =  "";
            $outTextHeader .=  "Content-Type: text/plain; charset=gb2312\n";
            $outTextHeader .=  "Content-Transfer-Encoding: 7bit\n\n";
            $outTextHeader .= $this->mailText. "\n";
            return $outTextHeader;
        }
    /*
      

  3.   

    第二部分:
    /*************返回一个图片的头信息************/    function formatImgHeader($inFileLocation){
            $outImgHeader =  "";
             //--通过文件扩展名获得 $contentType
            $contentType = $this->getContentType($inFileLocation);
            //--格式话头信息
                 $outImgHeader .=  "Content-Type: ".$contentType. ";\n";
                 $outImgHeader .=  ' name="'.basename($inFileLocation). '"'. "\n";
                 $outImgHeader .=  "Content-Transfer-Encoding: base64 \n";
                 $outImgHeader .=  "Content-ID:<".basename($inFileLocation).">\n\n";
                 exec( "uuencode -m $inFileLocation nothing_out",$returnArray);
                 //--   加入每一行的返回值
                 for ($i=1;$i<(count($returnArray));$i++){
                    $outImgHeader .= $returnArray[$i]. "\n";
                 }
                 $outImgHeader .=  "\n";
            return $outImgHeader;
        }
    /***********返回一个附件的头信息************/    function formatAttachmentHeader($inFileLocation){
            $outAttachmentHeader ="";
             //--通过文件的扩展名得到文件的$contentType
            $contentType = $this->getContentType($inFileLocation);
             //--如果文件是 TEXT类型,那么就用标准的7bit编码
            if(ereg( "txt",$contentType)){
                 //-- 格式化信息头
                $outAttachmentHeader .=  "Content-Type: ".$contentType.";\n";
                $outAttachmentHeader .=  'name="'.basename($inFileLocation).'"'."\n";
                $outAttachmentHeader .=  "Content-Transfer-Encoding: 7bit\n";
                $outAttachmentHeader .=  "Content-Disposition: attachment;\n";     //--other: inline
                $outAttachmentHeader .=  'filename="'.basename($inFileLocation).'"'."\n\n";
                $textFile = fopen($inFileLocation,"r");
                 //-- 一行一行的检查文件
                while(!feof($textFile)){                $outAttachmentHeader.= fgets($textFile,1000);
                }
                 //-- 关闭文件
                fclose($textFile);
                $outAttachmentHeader .=  "\n";
            }
             //--非TEXT类型,用64-bit编码
            else{
                 //--格式化头信息
                $outAttachmentHeader .=  "Content-Type: ".$contentType. ";\n";
                $outAttachmentHeader .=  'name="'.basename($inFileLocation).'"'."\n";
                $outAttachmentHeader .=  "Content-Transfer-Encoding: base64\n";
              //$outAttachmentHeader .= "Content-ID:<".basename($inFileLocation).">\n";
                $outAttachmentHeader .=  "Content-Disposition: attachment;\n";     //--other: inline
                $outAttachmentHeader .=  'filename="'.basename($inFileLocation).'"'."\n\n";
                 //--调用uuuencode 命令
                exec( "uuencode -m $inFileLocation nothing_out",$returnArray);
                 //--加入每一行的返回值
                for ($i = 1; $i<(count($returnArray)); $i++){
                    $outAttachmentHeader.= $returnArray[$i]."\n";
                }
            }
            return $outAttachmentHeader;
        }
      

  4.   

    第三部分:这三部分和到一气是完整的程序。
    /***************发送邮件*************/    function send(){
             //--把邮件头设为空
            $mailHeader =  "";
             //-- 加入抄送地址
            if($this->mailCC !=  "") $mailHeader .=  "CC: ".$this->mailCC. "\n";
             //--add 加入暗送地址
            if($this->mailBCC !=  "") $mailHeader .=  "BCC: ".$this->mailBCC. "\n";
             //--add 加入发信人地址
            if($this->mailFrom !=  "") $mailHeader .=  "FROM: ".$this->mailFrom. "\n";         //---------------信息类型---------------
             //--TEXT  文本
            if($this->mailText !=  "" && $this->mailHTML ==  "" && $this->mailAttachments ==  ""){
                return mail($this->mailTo,$this->mailSubject,$this->mailText,$mailHeader);
            }
             //--HTML 和 TEXT
            elseif($this->mailText !=  "" && $this->mailHTML !=  "" && $this->mailAttachments ==  ""){
                 //--得到一个随机边界
                $bodyBoundary = $this->getRandomBoundary();
                 //--格式化头信息
                $textHeader = $this->formatTextHeader();
                $htmlHeader = $this->formatHTMLHeader();
                 //--设置 MIME版本
                $mailHeader .=  "MIME-Version: 1.0\n";
                 //--set up main content header with boundary
                $mailHeader .=  "Content-Type: multipart/alternative;\n";
                $mailHeader .=  ' boundary="'.$bodyBoundary. '"';
                $mailHeader .=  "\n\n\n";
                 //-- 加入信体和边界
                $mailHeader .=  "--".$bodyBoundary. "\n";
                $mailHeader .= $textHeader;
                $mailHeader .=  "--".$bodyBoundary. "\n";
                 //--加入HTML和结束边界
                $mailHeader .= $htmlHeader;
              if($this->mailImg!="")
              {
                 //--加入HTML文件中的图片
                $ImgArray = explode( ",",$this->mailImg);
                 //--检查每一个图片
                for($i=0;$i<count($ImgArray);$i++){
                     //--图片分割标志
                     $mailHeader .=  "\n--".$bodyBoundary. "\n";
                     //--获得图片信息
                    $mailHeader .= $this->formatImgHeader($ImgArray[$i]);
                }
               }
                $mailHeader .=  "\n--".$bodyBoundary. "--";
                 //--发送信息
                return mail($this->mailTo,$this->mailSubject, "",$mailHeader);
            }
             //--HTML 和 TEXT 和 附件
            elseif($this->mailText !=  "" && $this->mailHTML !=  "" && $this->mailAttachments !=  ""){             //--获得附件的随机边界
                $attachmentBoundary = $this->getRandomBoundary();
                 //--set main header for all parts and boundary
                $mailHeader .=  "Content-Type: multipart/mixed;\n";
                $mailHeader .=  ' boundary="'.$attachmentBoundary. '"'. "\n\n";
                $mailHeader .=  "This is a multi-part message in MIME format.\n";
                $mailHeader .=  "--".$attachmentBoundary. "\n";             //--TEXT 和 HTML--
                 //--获得content types的随机边界
                $bodyBoundary = $this->getRandomBoundary(1);
                 //--格式化头信息
                $textHeader = $this->formatTextHeader();
                $htmlHeader = $this->formatHTMLHeader();
                 //--设置 MIME 版本
                $mailHeader .=  "MIME-Version: 1.0\n";
                 //-- 为所有部分和边界设置头信息
                $mailHeader .=  "Content-Type: multipart/alternative;\n";
                $mailHeader .=  ' boundary="'.$bodyBoundary. '"';
                $mailHeader .=  "\n\n\n";
                 //--加入信体和边界
                $mailHeader .=  "--".$bodyBoundary. "\n";
                $mailHeader .= $textHeader;
                $mailHeader .=  "--".$bodyBoundary. "\n";
                 //--加入HTML 和结尾边界
                $mailHeader .= $htmlHeader;
              if($this->mailImg!="")
              {
                 //--add html include images
                $ImgArray = explode( ",",$this->mailImg);
                 //-- 检查每一个图片
                for($i=0;$i<count($ImgArray);$i++){
                     //--图片分割标志
                     $mailHeader .=  "\n--".$bodyBoundary. "\n";
                     //--get images info
                    $mailHeader .= $this->formatImgHeader($ImgArray[$i]);
                }
               }
                   $mailHeader .=  "\n--".$bodyBoundary. "--";
                 //--send message
                 //--END TEXT AND HTML             //--get array of attachment filenames
                $attachmentArray = explode( ",",$this->mailAttachments);
                 //--loop through each attachment
                for($i=0;$i<count($attachmentArray);$i++){
                     //--attachment separator
                    $mailHeader .=  "\n--".$attachmentBoundary. "\n";
                     //--get attachment info
                    $mailHeader .= $this->formatAttachmentHeader($attachmentArray[$i]);
                }
                $mailHeader .=  "--".$attachmentBoundary. "--";
                return mail($this->mailTo,$this->mailSubject, "",$mailHeader);
            }elseif($this->mailText !=  "" && $this->mailHTML ==  "" && $this->mailAttachments !=  "")
            {
                //--得到附件的随机边界
                $attachmentBoundary = $this->getRandomBoundary();
                 //--为所有部分和边界设置头信息
                $mailHeader .=  "Content-Type: multipart/mixed;\n";
                $mailHeader .=  ' boundary="'.$attachmentBoundary. '"'. "\n\n";
                $mailHeader .=  "This is a multi-part message in MIME format.\n";
                $mailHeader .=  "--".$attachmentBoundary. "\n";
                 //--TEXT AND HTML--
                 //--get random boundary for content types
                $bodyBoundary = $this->getRandomBoundary(1);
                 //--格式化头信息
                $textHeader = $this->formatTextHeader();
                 //--$htmlHeader = $this->formatHTMLHeader();
                 //--set MIME-Version
                $mailHeader .=  "MIME-Version: 1.0\n";
                 //--set up main content header with boundary
                $mailHeader .=  "Content-Type: multipart/alternative;\n";
                $mailHeader .=  ' boundary="'.$bodyBoundary. '"';
                $mailHeader .=  "\n\n\n";
                 //--add body and boundaries
                $mailHeader .=  "--".$bodyBoundary. "\n";
                $mailHeader .= $textHeader;
            //--$mailHeader .=  "--".$bodyBoundary. "\n";
            //--add html and ending boundary
            //--$mailHeader .= $htmlHeader;
                $mailHeader .=  "\n--".$bodyBoundary. "--";
                 //--send message
                 //--END TEXT AND HTML
                 //--得到附件文件名数组
                $attachmentArray = explode( ",",$this->mailAttachments);
                 //--检索每一个附件
                for($i=0;$i<count($attachmentArray);$i++){
                     //--附件分割标志
                    $mailHeader .=  "\n--".$attachmentBoundary. "\n";
                     //--得到附件信息
                    $mailHeader .= $this->formatAttachmentHeader($attachmentArray[$i]);
                }
                $mailHeader .=  "--".$attachmentBoundary. "--";
                return mail($this->mailTo,$this->mailSubject,"",$mailHeader);
            }
            return false;
        }
    }
    function message($mess)
    {
       print "<table border=0 cellpadding=20 cellspacing=5 width=90%><tr><td align=center>MESSAGE</td></tr><tr><td align=center class=1050>$mess</td></tr>";
       print "<tr><td align=center><a href=\"javascript:window.history.go(-1);\" target=_self style=\"color=blue\">返回上一页</a></td></tr></table></body></html>";
       exit;
    }
    ?>
      

  5.   

    好复杂啊~
    这几段程序合在一起是不是就可以用mime发送带附件的邮件??
      

  6.   

    ./slave/$slave_name
    你确定有这个文件吗?
      

  7.   

    我确定在./slave/下有$slave_name文件。
    这就是用mime发送带附件的邮件的类。但是我发送的附件文件名不对,字节数
    总是0字节。请问这是怎么回事。请高手帮忙?
      

  8.   

    其实发送附件就是用一个copy()函数
      

  9.   

    lvxing(旅行) 可不可以把 http://www.phpbuilder.com/columns/kartic20000807.php3 的内容贴出来~~我在学校`~~连不上那边~~:(
      

  10.   

    to :lvxing(旅行) 
    这就是你说的?????~~~~~~~~
    (我看我们要好好看看英语先~~)  
    Tired of sending those drab textual notifications and newsletters to your friend and clients? Ever wanted to send attachments and/or HTML embedded email. The answer is MIME. The ensuing few pages explain the basics of MIME, creating MIME-compliant messages and then ends with a working class implementation of sending MIME complaint email in PHP. Note that references to calling script, caller etc. denote the script that uses the class we are about to develop and client/MUA etc. denote a mail reading client or mail user agent. 
    Some MIME basics
    MIME stand for Multipurpose Internet Mail Extensions. MIME extends the basic text-oriented Internet mail system in order that messages can contain binary attachments. MIME takes advantage of the fact that RFC 822 places little restriction on the message body content: the only stipulation is that plain ASCII text be used. Thus, MIME messages consist of normal Internet text mail with some special RFC 822 compliant headers and formatted bodies (with the attachments represented in a subset of ASCII). These MIME headers give a special meaning to the presence of attachments in your mail. 
    Anatomy of a MIME Message
    An ordinary text e-mail message contains a header portion (To: From: Subject: etc.) and a body portion (Hello Mr., etc.). In a MIME compliant message, there are also headers involved and not surprisingly, parts of the email called MIME parts, prefixed by special headers also. A MIME mail is just an extension of the RFC 822 based email. It however has its own set of RFCs. 
    Header Fields
    MIME headers are broadly classified as MIME Message Headers and MIME Part Headers, based on their placement in an email packet. The MIME Message Headers are: MIME-Version:
    This header provides the version number of MIME used. The value to be used is 1.0. 
    Content-Type:
    This identifies the type of data so that it can be handled suitably. Valid types are text, image, audio, video, applications, multipart and message. Note that arbitrary binary attachments must be called application/octet-stream. Some examples of this header are image/jpg, application/msword, multipart/mixed, to cite a few. 
    Content-Transfer-Encoding:
    This is the most important of all the headers as it shows the type of encoding performed on the data and is used by the client/MUA to decode the attachment. It can take one of 7bit, 8bit, binary, quoted-printable, base64 and custom, per attachment. 7bit encoding is the normal encoding used on US ASCII characters, i.e., retain it as it is. 8bit and binary encoding are not used in general. Quoted printable is used for human-readable normal text if it has to be protected in transit through a gateway that will affect the formatting. Base64 is a common denominator and gives a lazy approach to deciding which encoding to use; this is normally used on binary, non-textual data. Note that any non-7bit data must be encoded using a scheme such it can traverse Internet mail gateways! 
    Content-ID:
    This header is useful if Content-Type is message/external-body or multipart/alternative. This is outside the scope of this article. 
    Content-Description:
    This is an optional header. Free text descriptions of the contents of any message part. The descriptions must be us-ascii. 
    Content-Disposition:
    An experimental header, it is used to provide hints to the client/MUA whether to display attachments inline or as an attachment. 
    MIME part headers (headers that appear in the actual MIME "attachment" part), can have any of the above except the MIME-Version header. If a MIME header is part of the message block, it applies to the entire message. E.g., if Content-Transfer-Encoding appears in the Message header, it applies to the entire message body, but if it appears under a MIME part, it is applicable to only that part. 
    "Okay, how do I create MIME Compliant Messages?"
    With the above general description, let us now look at what exactly is in this so-called MIME Message! 
    The Simplest MIME Message
    This message has no parts to it, i.e., no "attachments". Nevertheless, for it to be a MIME message, it must have the necessary headers. 
    From: [email protected]
    To: 'Alex (the Great)' <[email protected]>
    Subject: Bucephalus
    MIME-Version: 1.0Hello Alexander,How's Bucephalus doing?This is nothing but a simple RFC-822 compliant message (text email) with the MIME header. Note that if no Content-Type header is specified, Content-Type: text/plain; charset='us-ascii' is assumed! Of course, it could be something slightly more complex like the following: 
    From: 'Alex (the Great)' <[email protected]>
    To: [email protected]
    Subject: re: Bucephalus
    MIME-Version: 1.0
    Content-Type: image/jpg;
    name='buce.jpg'
    Content-Transfer-Encoding: base64
    Content-Description: Take a look at him yourself<.....base64 encoded jpg image of Bucephalus...>"Hey, but I want to send a word document and also a picture of my doggie in the same email...!" goes one user! True enough, the sample shown above is too simple and does not have enough pulp to support the fancier and necessary aspects of modern day emailing. In fact, many mail clients will not even show the description field! This is where we encounter what is called "multipart messages". 
    Multipart Messages
    This concept allows us to send multiple items in the same email. For instance, let us assume that Alexander wanted to email [email protected] a picture of his horse, with its pedigree chart along with a polished note in the email! Such a simple requirement cannot be satisfied without the concept of multipart messages. In such a situation, we create a wrapper using the Content-Type Message header to "hold" the various part of the email, so that the recipient gets the picture, the pedigree chart and the nice note! The Content-Type header now has a value "multipart" to indicate that it is a complete email message and that the header merely encapsulates the information. Moreover, it has a subtype of "mixed" (after all an image, a pedigree chart and 7bit text message are not the same type, correct?). Let us look at what the whole picture looks like: 
    From: 'Alex (the Great)' <[email protected]>
    To: [email protected]
    Subject: re: Bucephalus
    MIME-Version: 1.0
    Content-Type: multipart/mixed;
    boundary="XX-1234DED00099A";
    Content-Transfer-Encoding: 7bitThis is a MIME Encoded Message--XX-1234DED00099A
    Content-Type: text/plain; charset=us-ascii
    Content-Transfer-Encoding: 7bitHi PHP,Attached you will find my horse, Bucephalus', pedigree chart and photo. Alex--XX-1234DED00099A
    Content-Type: image/jpg;
    name="buce.jpg";
    Content-Transfer-Encoding: base64
    Content-Description: "A photo of Bucephalus"<.....base64 encoded jpg image of Bucephalus...>--XX-1234DED00099A
    Content-Type: application/octet-stream;
    name="pedigree.doc"
    Content-Transfer-Encoding: base64
    Content-Description: "Pedigree Chart of the great horse"<.....base64 encoded doc (pedigree.doc) of Bucephalus...>--XX-1234DED00099A-Phew! Looks like a lot of work, does it not? Anyway, let us go over the details: if you notice the Content-Transfer-Encoding on the MIME Message Header, it says "7bit". Since the Content-Type is multipart/mixed, the encoding has to be one of 7bit, 8bit or binary, 7bit being the widely used format. 
    A message like this has a variety of information bundled in it. How will the client "know" to differentiate between the JPG image, the document and the plain text? You will notice a boundary="XX-1234DED00099A"; parameter after the Content-Type. This value tells apart the various contents of the mail. This is called the MIME Boundary Marker. The value for the boundary er must be as unique as possible to avoid confusions as to the extent (scope) of the mail. 
    ....................................
      

  11.   

    应该是啊
    你肯定有哪个地方编码挫位了
    要不怎么会是文件0字节,文件名错误呢~
    编码格式出错了
    smtp服务器要支持utf-8的
    不能使用ASCII码
    使用编码格式要使用printable模式(也是基于base64的)
      

  12.   

    一个是7位一个是8位
    当然要cut你了!
      

  13.   

    这个类有个问题,它是使用外部的uuuencode命令进行binary文件编码的,
    如果没有这个外部文件,就会出错了。
    boomshell,你是不是在window下用的这个类?
    如果是的,那可能就是这个问题了。exec( "uuencode -m $inFileLocation nothing_out",$returnArray); 将这一句改成使用php内部的编码函数,应该可以解决问题。
    (使用php内部的编码函数,就要先把文件内容读入变量)