频道直达 - 学院 - 下载 - 交易 - 特效 - 字库 - 手册 -排名-工具- 繁體
网页教学网站开发 设为首页
加入收藏
联系我们
建站搜索: 常用广告代码   用户注册 | 用户登陆
您当前的位置:中国建站之家 -> 网站开发设计技术教程 -> PHP教程 -> php写的发送附件的程序(一)

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

作者:未知  来源:转载  发布时间:2005-9-15 0:26:33  发布人:acx

减小字体 增大字体

    
   来源:Richard Heyes
  
   <?
  error_reporting(63);
  include('class.html_mime_mail.inc');
  
  /***************************************
  ** Example of usage.
  ***************************************/
  /***************************************
  ** Read the file background.gif into
  ** $backgrnd.
  ***************************************/
  $filename = 'background.gif';
  $backgrnd = fread($fp = fopen($filename, 'r'), filesize($filename));
  fclose($fp);
  
  /***************************************
  ** Read the file test.zip into $attachment.
  ***************************************/
  $filename = 'example.zip';
  $attachment = fread($fp = fopen($filename, 'r'), filesize($filename));
  fclose($fp);
  
  /***************************************
  ** Create the mail object. Optional headers
  ** argument. Do not put From: here, this
  ** will be added when $mail->send
  ***************************************/
  $mail = new html_mime_mail("X-Mailer: Html Mime Mail Class\r\n");
  
  /***************************************
  ** If sending an html email, then these
  ** two variables specify the text and
  ** html versions of the mail. Don't
  ** have to be named as these are. Just
  ** make sure the names tie in to the
  ** $mail->add_html() command further down.
  ***************************************/
  $text = 'This is a test.';
  $html = '<HTML><BODY BACKGROUND="background.gif"><FONT FACE="Verdana, Arial" COLOR="#FF0000">    Success!</FONT><P></BODY></HTML>';
  
  /***************************************
  ** Add the text, html and embedded images.
  ** Each embedded image has to be added
  ** using $mail->add_html_image() BEFORE
  ** calling $mail->add_html(). The name
  ** of the image should match exactly
  ** (case-sensitive) to the name in the html.
  ***************************************/
  $mail->add_html_image($backgrnd, 'background.gif', 'image/gif');
  $mail->add_html($html, $text);
  
  /***************************************
  ** If not sending an html email, then
  ** this is used to set the plain text
  ** body of the email.
  ***************************************/
  // $mail->body = 'fsss';
  
  /***************************************
  ** This is used to add an attachment to
  ** the email.
  ***************************************/
  $mail->add_attachment($attachment, 'example.zip', 'application/octet-stream');
  
  /***************************************
  ** Builds the message.
  ***************************************/
  $mail->build_message();
  
  /***************************************
  ** Sends the message. $mail->build_message()
  ** is seperate to $mail->send so that the
  ** same email can be sent many times to
  ** differing recipients simply by putting
  ** $mail->send() in a loop.
  ***************************************/
  $mail->send('','szw@phpexe.com', 'From Name', 'szw@phpexe.com', 'Subject','');
  
  /***************************************
  ** Debug stuff. Entirely unnecessary.
  ***************************************/
  echo '<PRE>';
  echo $mail->mime;
  echo '</PRE>';
  ?>
  


将本文收藏到QQ书签与更多好友分享
[打 印]
[] [返回上一页] [收 藏]
上一篇文章:定制php4的session功能
∷相关文章评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论...]
精彩推荐
热门文章
· 注册码大全二
· 注册码大全四
· 注册码大全一
· 要10G免费网络硬盘的请进..
· 通过google 赶快来赚美金..
· 注册码大全十
· 头像-qq头像(qq新头像)4..
· 让你轻松架设FTP服务器1..
· 注册码大全三
· 梦幻背景图片7
· 卡通动物图片6
· 网页制作素材-按钮素材2..
· 让你轻松架设FTP服务器5..
· 风景图片8
· 注册码大全九
· 让你轻松架设FTP服务器2..
关注此文读者还看过
· 看好网络应用前景 英特尔..
· photoshop中制作逼真的鼠..
· 在Flash MX中实现自由拖..
· 网站推广之搜索引擎篇
· 仿小小的控制菜单 第十二..
· PhotoShop鼠绘奥迪轿车
· 学网页设计与网页制作,..
· VBScript 数据类型
· 夏日风情-椰岛风(2)
· Google卷入色情案 不配合..
· 一点ASP问题、差错和个人..
· ASP 3.0高级编程(三十五..
· 在IE中调用Dreamweaver编..
· 3d圆环旋
· 视频网站YouTube再遭起诉..
· 做网页的一些技巧(续)..
相关文章
· 30分钟学会用PHP写带数据库..
· 30分钟学会用PHP写带数据库..
· php写的发送附件的程序(二)..
· 用php写的serv-u的web申请账..
· 一个用mysql_odbc和php写的..
· 模仿PHP写的ASP 分页
· php写的域名查询系统whois
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图 - 人才招聘
网站合作、内容监督、商务咨询:QQ: 9576619
Copyright ? 2005--2008 中国建站之家版权所有
粤ICP备05092265号