编程教程
你的位置: 中国个人站长站 -- 网络编程 -- PHP教程 -- 教程正文 PHP教程.应用实例10
推荐位

PHP教程.应用实例10

中国个人站长站 PHP教程 点击数: 更新时间:2007-7-28 3:51:47
php写的发送附件的程序(二)
<?php
class html_mime_mail{

var $headers;
var $body;
var $multipart;
var $mime;
var $html;
var $html_text;
var $html_images = array();
var $cids = array();
var $do_html;
var $parts = array();

/***************************************
** Constructor function. Sets the headers
** if supplied.
***************************************/
function html_mime_mail($headers = ''''){
$this->headers = $headers;
}

/***************************************
** Adds a html part to the mail.
** Also replaces image names with
** content-id''s.
***************************************/
function add_html($html, $text){
$this->do_html = 1;
$this->html = $html;
$this->html_text = $text;
if(is_array($this->html_images) AND count($this->html_images) > 0){
for($i=0; $i<count($this->html_images); $i++){
$this->html = ereg_replace($this->html_images[$i][''name''], ''cid:''.$this->html_images[$i][''cid''], $this->html);
}
}
}

/***************************************
** Builds html part of email.
***************************************/
function build_html($orig_boundary){
$sec_boundary = ''=_''.md5(uniqid(time()));
$thr_boundary = ''=_''.md5(uniqid(time()));

if(!is_array($this->html_images)){
$this->multipart.= ''--''.$orig_boundary."\r\n";
$this->multipart.= ''Content-Type: multipart/alternative; boundary="''.$sec_boundary."\"\r\n\r\n\r\n";

$this->multipart.= ''--''.$sec_boundary."\r\n";
$this->multipart.= ''Content-Type: text/plain''."\r\n";
$this->multipart.= ''Content-Transfer-Encoding: 7bit''."\r\n\r\n";
$this->multipart.= $this->html_text."\r\n\r\n";

$this->multipart.= ''--''.$sec_boundary."\r\n";
$this->multipart.= ''Content-Type: text/html''."\r\n";
$this->multipart.= ''Content-Transfer-Encoding: 7bit''."\r\n\r\n";
$this->multipart.= $this->html."\r\n\r\n";
$this->multipart.= ''--''.$sec_boundary."--\r\n\r\n";
}else{
$this->multipart.= ''--''.$orig_boundary."\r\n";
$this->multipart.= ''Content-Type: multipart/related; boundary="''.$sec_boundary."\"\r\n\r\n\r\n";

$this->multipart.= ''--''.$sec_boundary."\r\n";
$this->multipart.= ''Content-Type: multip

[1] [2] [3] [4] 下一页

教程录入:swh    责任编辑:swh 
个人站长站与你风雨同舟!
本站所提供的资源均来源于互联网,如有侵权行为,请与本站管理员联系,我们会第一时间删除!
·如果您发现《PHP教程.应用实例10》文章有错误,也请通知我们修改!
联系邮箱chinageren#126.com,谢谢支持!
站内搜索:
广告服务 | 友情链接 | 联系我们 | 免责声明 | 用户留言 | 网站导航
版权所有:中国个人站长站 2007-2008 未经授权禁止复制或建立镜像 客服QQ号:112731235
copyright © 2007-2008 www.ChinaGeRen.com online services. all rights reserved. 苏ICP备05000059号