快精灵印艺坊 您身边的文印专家
广州名片 深圳名片 会员卡 贵宾卡 印刷 设计教程
产品展示 在线订购 会员中心 产品模板 设计指南 在线编辑
 首页 名片设计   CorelDRAW   Illustrator   AuotoCAD   Painter   其他软件   Photoshop   Fireworks   Flash  

 » 彩色名片
 » PVC卡
 » 彩色磁性卡
 » 彩页/画册
 » 个性印务
 » 彩色不干胶
 » 明信片
   » 明信片
   » 彩色书签
   » 门挂
 » 其他产品与服务
   » 创业锦囊
   » 办公用品
     » 信封、信纸
     » 便签纸、斜面纸砖
     » 无碳复印纸
   » 海报
   » 大篇幅印刷
     » KT板
     » 海报
     » 横幅

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

    
   来源: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 Classrn");
  
  /***************************************
  ** 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>\\';
  ?>
  


返回类别: 教程
上一教程: LAMPJT最适用的web开发系统具体配置
下一教程: 编译php的配置参数

您可以阅读与"php写的发送附件的程序(一)"相关的教程:
· 用php写的serv-u的web申请账号的程序
· 用php发送带附件的Email
· 以文本方法上传二进制文件的PHP程序
· 简朴的用PHP编写的导航条程序
· 用PHP写的身份证验证程序
    微笑服务 优质保证 索取样品