• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

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

发布: 2007-7-01 15:06 | 作者: admin | 来源: | 查看: 15次 | 进入软件测试论坛讨论

领测软件测试网     
   来源: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>@#;
  ?>
  

延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网