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

她们叫我蔡货

她们叫我蔡货

2016-01-29 15:23

php写的发送附件的程序(一),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','');
  
  /************************************
展开更多 50%)
分享

猜你喜欢

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

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

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

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

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

用php发送带附件的Email

PHP
用php发送带附件的Email

用PHP发送有附件的电子邮件

PHP
用PHP发送有附件的电子邮件

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

一个可以发送附件及HTML格式邮件的PHP类

Web开发
一个可以发送附件及HTML格式邮件的PHP类

SMTP协议-PHP的邮件发送程序例子

Web开发
SMTP协议-PHP的邮件发送程序例子

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

《DQM:特瑞仙境》图解黄金史莱姆配方

《DQM:特瑞仙境》图解黄金史莱姆配方

在Linux下安装PHP,APACHE,ORACLE,PERL的方法

在Linux下安装PHP,APACHE,ORACLE,PERL的方法
下拉加载更多内容 ↓