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

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

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

【 tulaoshi.com - 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','');
  
  /************************************

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

延伸阅读
标签: PHP
  <html   <head   <meta http-equiv="Content-Type" content="text/html; charset=gb2312"   <title查询条件</title   <meta name="GENERATOR" content="Microsoft FrontPage 3.0"   </head   <body bg...
标签: 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...
标签: PHP
在开始这篇文章时,作者假设读者已能够写出一个用户的登入认证程序. ---------------------------------------------------------- 记数器可完成访问 web 页的总次数,但却不能得知一个时段中访问量的动态记载,下面就来介绍如何写一个各个时段动态显示访问量的方法. 要记载访问量,首先就要在 mysql 内建立一个数据库,姑且给这...

经验教程

306

收藏

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