你的这个HTML的邮件要在哪个地方发送?比喻说,在电子邮件客户端发送,还是在免费油箱中发送?

解决方案 »

  1.   

    给你个class<?
    Class sendMailPro { 
        var $to       = array();    // &Ecirc;&Otilde;&ETH;&Aring;&Egrave;&Euml; 
        var $from     = "";         // ·&cent;&ETH;&Aring;&Egrave;&Euml; 
        var $headers  = "";         // &Iacute;·&ETH;&Aring;&Iuml;&cent; 
        var $subject  = "";         // &Ouml;÷&Igrave;&acirc; 
        var $body     = "";         // &Auml;&Uacute;&Egrave;&Yacute; 
        var $mime     = "";         // Mime&ETH;&Aring;&Iuml;&cent; 
        var $parts    = array();    // &cedil;&frac12;&frac14;&thorn; 
        var $filec;                 // &Icirc;&Auml;&frac14;&thorn;&Ecirc;&yacute;&Auml;&iquest; 
        var $boundary = "";         // ·&Ouml;&cedil;&ocirc;·&ucirc; 
        var $type     = "text/plain"; 
        function sendMailPro($to, $from = "", $subject = "",$body = "", $headers = "") { 
            if(is_array($to)) { 
                $this->to    = $to; 
            } else { 
                $this->to[0] = $to; 
            } 
            $this->from      = $from; 
            $this->subject   = $subject; 
            $this->body      = $body; 
            $this->headers   = $headers;         $this->boundary  = Chop("b".md5(uniqid(time()))); 
        } 
        function addreciever($to) { 
            $this->to[]      = $to; 
            return 1; 
        } 
        function addAttachment($filecontent, $filename = "", $filetype = "application/octet-stream") { 
            $this->filec++; 
            if($filename=="") { 
                $filename = "attachment_".$this->filec; 
            } 
            $this->parts[] = array( 
                "type" => $filetype, 
                "content" => $filecontent, 
                "name" => $filename 
            ); 
            return 1; 
        } 
        function addFile($filename) { 
            $filecontent = fread(fopen($filename,"r"), filesize($filename)); 
            $filetype    = "application/octet-stream"; 
            $this->addAttachment($filecontent, $filename, $filetype); 
        } 
        function buildBody() { 
            $body =$this->body; 
            $boundary = $this->boundary; 
            $bodyr = "--".$boundary; 
            $bodyr = "\nContent-Type: ".$this->type."; charset=\"GB2312\"\nContent-Transfer-Encoding: quoted-printable\n\n"; 
            $bodyr.= $body."\n\n"; 
            $bodyr.= "--".$boundary; 
            return $bodyr; 
        } 
        function buildContent($part) { 
            $content  = $part["content"]; 
    //        $content  = chunk_split(base64_encode($content)); 
            $encoding = "base64"; 
            $return   = "Content-Type: ".$part["type"].";"; 
            $return  .= " name = \"".$part["name"]."\"\n"; 
            $return  .= "Content-Transfer-Encoding: $encoding\n"; 
            $return  .= "Content-Disposition: attachment; filename=\"".$part["name"]."\"\n\n"; 
            $return  .= "$content\n"; 
            return $return; 
        } 
        function buildMail() { 
            $boundary = $this->boundary; 
            $multipart = "Content-Type: multipart/mixed; boundary = \"$boundary\"\n\nThis is a MIME encoded message send by sendMailPro class(zlib).\n\n--$boundary"; 
            $multipart.= $this->buildBody(); 
            $attachmentCount = count($this->parts); 
            if($attachmentCount==0) { 
                return $multipart; 
            } 
            for($i = $attachmentCount-1;$i>=0;$i--){ 
                $multipart .= "\n".$this->buildContent($this->parts[$i])."--$boundary"; 
            } 
            $multipart = chop($multipart); 
            $multipart.= "--\n"; 
            return $multipart; 
        } 
        function isHtml($html = 'yes') { 
            if($html) { 
                $this->type = "text/html"; 
            } 
            return 1; 
        } 
        function send() { 
            if($this->from<>'') { 
                $this->mime.= "From: ".$this->from."\n"; 
            } 
            $this->mime.= "MIME-Version: 1.0\n"; 
            $this->mime.= $this->buildMail(); 
            $to_count = count($this->to); 
            for($i = 0;$i<$to_count;$i++) { 
                mail($this->to[$i], $this->subject, "", $this->mime); 
            } 
            return 1; 
        } 
        function attachmentCount() { 
            return $this->filec; 
        } 

    ?>
      

  2.   

    中文注释没有了,或者你来信要。[email protected]
      

  3.   

    在mail函数的第四个参数中添加这个
    Content-Type: text/html; charset="GB2312"