php写的发送附件的程序(二)

2016-01-29 15:23 6 1 收藏

php写的发送附件的程序(二),php写的发送附件的程序(二)

【 tulaoshi.com - PHP 】

      
  
   来源:Richard Heyes
  
   <?php
  class html_mime_mail{
  
  var $headers;
  var $body;
  var $multipart;
  var $mime;
  var $html;
  var $html_text;
  var $html_images = array();
  var $cids = array();
  var $do_html;
  var $parts = array();
  
  /***************************************
  ** Constructor function. Sets the headers
  ** if supplied.
  ***************************************/
  function html_mime_mail($headers = ''){
  $this->headers = $headers;
  }
  
  /***************************************
  ** Adds a html part to the mail.
  ** Also replaces image names with
  ** content-id's.
  ***************************************/
  function add_html($html, $text){
  $this->do_html = 1;
  $this->html = $html;
  $this->html_text = $text;
  if(is_array($this->html_images) AND count($this->html_images) > 0){
  for($i=0; $i<count($this->html_images); $i++){
  $this->html = ereg_replace($this->html_images[$i]['name'], 'cid:'.$this->html_images[$i]['cid'], $this->html);
  }
  }
  }
  
  /***************************************
  ** Builds html part of email.
  ***************************************/
  function build_html($orig_boundary){
  $sec_boundary = '=_'.md5(uniqid(time()));
  $thr_boundary = '=_'.md5(uniqid(time()));
  
  if(!is_array($this->html_images)){
  $this->multipart.= '--'.$orig_boundary."rn";
  $this->multipart.= 'Content-Type: multipart/alternative; boundary="'.$sec_boundary.""rnrnrn";
  
  $this->multipart.= '--'.$sec_boundary."rn";
  $this->multipart.= 'Content-Type: text/plain'."rn";
  $this->multipart.= 'Content-Transfer-Encoding: 7bit'."rnrn";
  $this->multipart.= $this->html_text."rnrn";
  
  $this->multipart.= '--'.$sec_boundary."rn";
  $this->multipart.= 'Content-Type: text/html'."rn";
  $this->multipart.= 'Content-Transfer-Encoding: 7bit'."rnrn";
  $this->multipart.= $this->html."rnrn";
  $this->multipart.= '--'.$sec_boundary."--rnrn";
  }else{
  $this->multipart.= '--'.$orig_boundary."rn";
  $this->multipart.= 'Content-Type: multipart/related; boundary="'.$sec_boundary.""rnrnrn";
  
  $this->multipart.= '--'.$sec_boundary."rn";
  $this->multipart.= 'Content-Type: multipart/alternative; boundary="'.$thr_boundary.""rnrnrn";
  
  $this->multipart.= '--'.$thr_boundary."rn";
  $this->multipart.= 'Content-Type: text/plain'."rn";
  $this->multipart.= 'Content-Transfer-Encoding: 7bit'."rnrn";
  $this->multipart.= $this->html_text."rnrn";
  
  $this->multipart.= '--'.$thr_boundary."rn";
  $this->multipart.= 'Content-Type: text/html'."rn";
  $this->multipart.= 'Content-Transfer-Encoding: 7bit'."rnrn";
  $this->multipart.= $this->html."rnrn";
  $this->multipart.= '--'.$thr_boundary."--rnrn";
  
  for($i=0; $i<count($this->html_images); $i++){
  $this->multipart.= '--'.$sec_boundary."rn";
  $this->build_html_image($i);
  }
  
  $this->multipart.= "--

来源:https://www.tulaoshi.com/n/20160129/1495775.html

延伸阅读
标签: PHP
         本章介绍了如何编译及安装gcc C编译器、MySQL数据库和带有PHP模块的Apache Web 服务器。如果使用者不能确定自己计算机需要那些组件,请完全安装。      本章的安装指令是以新的Red Hat Linux v5.2和v6.0为基础的。由于安装在v5.2上的C编译器版本不够新,以至于不...
这里我给大家提供一个很实用的例子,就是在线发送ICQ信息。想一想我们在网页上直接给朋友发送ICQ信息,那是多么美妙的事情啊。呵呵,在吹牛啊,其实ICQ本来就有在线发送的代码,不过,这些都是AOL给你写好的代码,多没有意思啊。还是自已写的比较好,呵呵,废话少说,大家来看代码吧 <br <br <% @ Page Language="C#" % <br <% @ ...
标签: PHP
  <? //Sign.php //系统适用于win2000 $path="e:\\serv-u\\ServUDaemon.ini";//用户文件的路径 $fabu="e:\\web\\";//总web路径 if($add) { $fp1=fopen($path,"r+"); $str=fread($fp1, filesize($path)); $fp=fopen($path,"a"); flock($fp,3); $us="=".$userid; $start=strpos($str,$us); if($start)     { echo "对不...
标签: 电脑入门
发送超大邮件对于Windows系统用户来说,是件很容易的事,不过对于MAC用户来说,却不是这样。新发布的 Mac OS 10.10 Yosemite 系统终于解决了这个大难题,现在就让图老师小编给大家介绍一下在Mac OS 10.10 Yosemite 系统中如何发送超大邮件吧。 Mac 发送超大附件的操作方法: 1、当然,要想使用最新的 MailDrop 功能,需要你升级为最新的...
发送邮件的主程序 import java.util.Properties; import common.util.Email_Autherticatorbean; import javax.mail.Authenticator; import javax.mail.internet.InternetAddress; import org.apache.commons.lang.StringUtils; import javax.mail.internet.MimeBodyPart; import javax.mail.Multipa...

经验教程

592

收藏

12
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部