答案:<?php
if(basename($PHP_SELF)== "class.html_mime_mail.inc")
{
include "fileinfo.inc";
echo "<pre>
如果不含圖檔:
\$mail = new html_mime_mail();
\$html =\"HTML內容\";
\$mail->add_html(\$html, \$text);
\$mail->build_message();
\$mail->send(收信人,收信Email,發信人,發信Email,標題,額外Header);
<hr>
如果含圖檔:
\$url=\"www.cuti.com.my/AD/\"; //圖檔位?FONT color="#007700">} ?FONT color="#007700">}頭無http:// 結尾有斜線
\$path=\"/MAIL/AD/\"; //圖檔路徑 結尾有斜線
\$filename1 = 'a.jpg';
\$backgrnd1 = fread(\$fp = fopen(\$path.\$filename1, 'r'), filesize(\$path.\$filename1));
fclose(\$fp);
...依此類推...
\$filename6 = 'f.gif';
\$backgrnd6 = fread(\$fp = fopen(\$path.\$filename6, 'r'), filesize(\$path.\$filename6));
fclose(\$fp);
\$mail->add_html_image(\$backgrnd1,\$filename1,'image/jpeg','http://'.\$url.\$filename1);
...依此類推...
\$mail->add_html_image(\$backgrnd6,\$filename6,'image/gif','http://'.\$url.\$filename6);
\$mail = new html_mime_mail();
\$html =\"HTML含圖內容\";
\$mail->add_html(\$html, \$text);
\$mail->build_message();
\$mail->send(收信人,收信Email,發信人,發信Email,標題,額外Header);
";
}
/***************************************
** Title.........: HTML Mime Mail class
** Version.......: 1.26
** Author........: Richard Heyes <richard.heyes@heyes-computing.net>
** Filename......: html_mime_mail.class
** Last changed..: 25/06/2000
** Notes.........: Based upon mime_mail.class
** by Tobias Ratschiller <tobias@dnet.it>
** and Sascha Schumann <sascha@schumann.cx>.
** - Thanks to Thomas Flemming for supplying a fix
** for Win32.
** - Made headers terminated by CRLF instead of LF, now
** compliant with RFC822. Thanks to Pao-Hsi Huang.
** - Fixed bug; certain mail systems (gmx.net in particular)
** were rejecting mail because of a space character either
** side of the equal sign on the boundary line. Thanks to
** Peter Holm for notifying me.
** - Fixed bug; $html_images was tested to be an array or not
** but was set to be an array during object creation, so the
** test always returned true. Thanks to Bob Silva for
** notifying me.
** - Fixed bug; when looping with $obj->send(), From: headers
** were accumulating. Bummer. Thanks to Lance Rasmussen for
** notifying me.
** - See http://www.heyes-computing.net/scripts/ for a zip/tar
** containing an example script.
***************************************/
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++){
&n
上一个:发送mime邮件类--实例
下一个:RFC821-简单邮件传输协议(SMTP)中文版 - 1