一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

php實現(xiàn)的發(fā)送帶附件郵件類實例

本文實例講述了php實現(xiàn)的發(fā)送帶附件郵件類的方法,是一個非常實用的功能。分享給大家供大家參考。具體方法如下:

emailclass.php類文件如下:

<? class CMailFile {     var $subject;    var $addr_to;    var $text_body;    var $text_encoded;    var $mime_headers;    var $mime_boundary = "--==================_846811060==_";    var $smtp_headers;       function CMailFile($subject,$to,$from,$msg,$filename,$downfilename,$mimetype = "application/octet-stream",$mime_filename = false) {      $this->subject = $subject;         $this->addr_to = $to;         $this->smtp_headers = $this->write_smtpheaders($from);     $this->text_body = $this->write_body($msg);     $this->text_encoded = $this->attach_file($filename,$downfilename,$mimetype,$mime_filename);     $this->mime_headers = $this->write_mimeheaders($filename, $mime_filename);   }     function attach_file($filename,$downfilename,$mimetype,$mime_filename) {     $encoded = $this->encode_file($filename);     if ($mime_filename) $filename = $mime_filename;     $out = "--" . $this->mime_boundary . "/n";     $out = $out . "Content-type: " . $mimetype . "; name=/"$filename/";/n";     $out = $out . "Content-Transfer-Encoding: base64/n";     $out = $out . "Content-disposition: attachment; filename=/"$downfilename/"/n/n";     $out = $out . $encoded . "/n";     $out = $out . "--" . $this->mime_boundary . "--" . "/n";     return $out;   }     function encode_file($sourcefile) {      if (is_readable($sourcefile)) {        $fd = fopen($sourcefile, "r");        $contents = fread($fd, filesize($sourcefile));        $encoded = chunk_split(base64_encode($contents));        fclose($fd);      }      return $encoded;    }     function sendfile() {       $headers = $this->smtp_headers . $this->mime_headers;      $message = $this->text_body . $this->text_encoded;      mail($this->addr_to,$this->subject,$message,$headers);    }     function write_body($msgtext) {      $out = "--" . $this->mime_boundary . "/n";      $out = $out . "Content-Type: text/plain; charset=/"us-ascii/"/n/n";      $out = $out . $msgtext . "/n";      return $out;    }     function write_mimeheaders($filename, $mime_filename) {      if ($mime_filename) $filename = $mime_filename;      $out = "MIME-version: 1.0/n";      $out = $out . "Content-type: multipart/mixed; ";      $out = $out . "boundary=/"$this->mime_boundary/"/n";      $out = $out . "Content-transfer-encoding: 7BIT/n";      $out = $out . "X-attachments: $filename;/n/n";      return $out;    }     function write_smtpheaders($addr_from) {      $out = "From: $addr_from/n";      $out = $out . "Reply-To: $addr_from/n";      $out = $out . "X-Mailer: php3/n";      $out = $out . "X-Sender: $addr_from/n";      return $out;    }  }   /*用法 - 例如:mimetype 為 "image/gif"   $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filename,$mimetype);   $mailfile->sendfile();    $subject -- 主題   $sendto -- 收信人地址   $replyto -- 回復地址   $message -- 信件內容   $filename -- 附件文件名   $downfilename -- 下

主站蜘蛛池模板:
欧美成人精品福利在线视频
|
久久亚洲伊人中字综合精品
|
亚洲国产天堂久久综合图区
|
亚洲人成伊人成综合网久久久
|
91免费视频版
|
午夜a毛片
|
国产精品免费大片一区二区
|
欧美xxxx做受欧美人妖
|
国产日韩精品欧美在线ccc
|
亚洲欧美一区二区久久
|
精品伊人|
91精品一区二区三区久久久久
|
欧美高清另类videosbestsex
|
色友网
|
国产午夜视频在线观看第四页
|
日韩中文字幕免费在线观看
|
亚洲人体视频
|
久草中文在线视频
|
日韩三级
|
最近最新中文字幕在线第一页
|
伊人久久大香线蕉综合热线
|
日韩中文字幕在线播放
|
美女掰开逼
|
成年午夜视频免费观看视频
|
91麻豆精品国产91久久久
|
www.色在线|
婷婷久久精品
|
欧美天天影院
|
九九精品视频在线观看
|
99视频热
|
久久中精品中文
|
2021久久精品免费观看
|
日本一区二区三区久久久久
|
男人扒开女人腿使劲桶动态图
|
国产夫妻小视频
|
欧美有码视频
|
亚洲免费二区三区
|
国产精品1024永久观看
|
麻豆91精品91久久久
|
91香蕉嫩草|
婷婷网五月天天综合天天爱
|