search

if(basename($PHP_SELF)== "class.html_mime_mail.inc")
{
  include  "fileinfo.inc";
  echo  "

<br>
    如果不含圖檔:<br>
     \$mail = new html_mime_mail();<br>
     \$html =\"HTML內容\";<br>
     \$mail->add_html(\$html, \$text);<br>
     \$mail->build_message();<br>
     \$mail->send(收信人,收信Email,發信人,發信Email,標題,額外Header);<br>
<br>
    <hr><br>
    如果含圖檔:<br>
    \$url=\"www.cuti.com.my/AD/\";    //圖檔位?FONT color="#007700">} ?FONT color="#007700">}頭無http:// 結尾有斜線<br>
    \$path=\"/MAIL/AD/\";    //圖檔路徑 結尾有斜線<br>
<br>
    \$filename1 = 'a.jpg';<br>
    \$backgrnd1 = fread(\$fp = fopen(\$path.\$filename1, 'r'), filesize(\$path.\$filename1));<br>
    fclose(\$fp);<br>
    ...依此類推...<br>
    \$filename6 = 'f.gif';<br>
        \$backgrnd6 = fread(\$fp = fopen(\$path.\$filename6, 'r'), filesize(\$path.\$filename6));<br>
        fclose(\$fp);<br>
    <br>
    \$mail->add_html_image(\$backgrnd1,\$filename1,'image/jpeg','http://'.\$url.\$filename1);<br>
    ...依此類推...<br>
    \$mail->add_html_image(\$backgrnd6,\$filename6,'image/gif','http://'.\$url.\$filename6);<br>
<br>
     \$mail = new html_mime_mail();<br>
     \$html =\"HTML含圖內容\";<br>
     \$mail->add_html(\$html, \$text);<br>
     \$mail->build_message();<br>
     \$mail->send(收信人,收信Email,發信人,發信Email,標題,額外Header);<br>
  ";<br>
        <br>
}<br>
/***************************************<br>
** Title.........: HTML Mime Mail class<br>
** Version.......: 1.26<br>
** Author........: Richard Heyes <richard.heyes><br>
** Filename......: html_mime_mail.class<br>
** Last changed..: 25/06/2000<br>
** Notes.........: Based upon mime_mail.class<br>
**                 by Tobias Ratschiller <tobias><br>
**                 and Sascha Schumann <sascha>.<br>
**                  - Thanks to Thomas Flemming for supplying a fix<br>
**                    for Win32.<br>
**                  - Made headers terminated by CRLF instead of LF, now<br>
**                    compliant with RFC822. Thanks to Pao-Hsi Huang.<br>
**                  - Fixed bug; certain mail systems (gmx.net in particular)<br>
**                    were rejecting mail because of a space character either<br>
**                    side of the equal sign on the boundary line. Thanks to<br>
**                    Peter Holm for notifying me.<br>
**                  - Fixed bug; $html_images was tested to be an array or not<br>
**                    but was set to be an array during object creation, so the<br>
**                    test always returned true. Thanks to Bob Silva for<br>
**                    notifying me.<br>
**                  - Fixed bug; when looping with $obj->send(), From: headers<br>
**                    were accumulating. Bummer. Thanks to Lance Rasmussen for<br>
**                    notifying me.<br>
**                  - See http://www.heyes-computing.net/scripts/ for a zip/tar<br>
**                    containing an example script.<br>
***************************************/ <br>
<br>
class html_mime_mail{<br>
<br>
        var $headers;<br>
        var $body;<br>
        var $multipart;<br>
        var $mime;<br>
        var $html;<br>
        var $html_text;<br>
        var $html_images = array();<br>
        var $cids = array();<br>
        var $do_html;<br>
        var $parts = array();<br>
<br>
/***************************************<br>
** Constructor function. Sets the headers<br>
** if supplied.<br>
***************************************/ <br>
        function html_mime_mail($headers =  '){<br>
                $this->headers = $headers;<br>
        }<br>
<br>
/***************************************<br>
** Adds a html part to the mail.<br>
** Also replaces image names with<br>
** content-id's.<br>
***************************************/ <br>
        function add_html($html, $text){<br>
                $this->do_html = 1;<br>
                $this->html = $html;<br>
                $this->html_text = $text;<br>
                if(is_array($this->html_images) AND count($this->html_images) > 0){<br>
                 /*      for($i=0; $i<count>html_images); $i++){<br>
                                $this->html = ereg_replace($this->html_images[$i]['name'], 'cid:'.$this->html_images[$i]['cid'], $this->html);<br>
                        }<br>
        */ <br>
                }<br>
        }<br>
<br>
/***************************************<br>
** Builds html part of email.<br>
***************************************/ <br>
        function build_html($orig_boundary){<br>
                $sec_boundary =  '=_'.md5(uniqid(time()));<br>
                $thr_boundary =  '=_'.md5(uniqid(time()));<br>
<br>
                if(count($this->html_images) == 0){<br>
                        $this->multipart.=  '--'.$orig_boundary. "\n";<br>
                        $this->multipart.=  'Content-Type: multipart/alternative;'.chr(10).chr(9). 'boundary="'.$sec_boundary. "\"\n\n\n";<br>
<br>
// ttj added below <br>
                        $this->multipart.=  '--'.$thr_boundary. "\n";<br>
                        $this->multipart.=  'Content-Type: text/plain'. "\n\n";<br>
                        $this->multipart.= $this->html_text. "\n\n";<br>
                        $this->multipart.=  '--'.$thr_boundary. "--\n\n";<br>
// ttj added above <br>
                        $this->multipart.=  '--'.$sec_boundary. "\n";<br>
                        $this->multipart.=  'Content-Type: text/plain'. "\n";<br>
                        $this->multipart.=  'Content-Transfer-Encoding: base64'. "\n\n";<br>
                        $this->multipart.= chunk_split(base64_encode($this->html_text)). "\n\n";<br>
// ttj added below <br>
                        $this->multipart.=  '--'.$thr_boundary. "\n";<br>
                        $this->multipart.=  'Content-Type: text/html'. "\n\n";<br>
                        $this->multipart.= $this->html. "\n\n";<br>
                        $this->multipart.=  '--'.$thr_boundary. "--\n\n";<br>
// ttj added above <br>
<br>
                        $this->multipart.=  '--'.$sec_boundary. "\n";<br>
                        $this->multipart.=  'Content-Type: text/html'. "\n";<br>
                        $this->multipart.=  'Content-Transfer-Encoding: base64'. "\n\n";<br>
                        $this->multipart.= chunk_split(base64_encode($this->html)). "\n\n";<br>
                        $this->multipart.=  '--'.$sec_boundary. "--\n\n";<br>
                }else{<br>
                        $this->multipart.=  '--'.$orig_boundary. "\n";<br>
                        $this->multipart.=  'Content-Type: multipart/related;'.chr(10).chr(9). 'boundary="'.$sec_boundary. "\"\n\n\n";<br>
<br>
                        $this->multipart.=  '--'.$sec_boundary. "\n";<br>
                        $this->multipart.=  'Content-Type: multipart/alternative;'.chr(10).chr(9). 'boundary="'.$thr_boundary. "\"\n\n\n";<br>
<br>
                        $this->multipart.=  '--'.$thr_boundary. "\n";<br>
                        $this->multipart.=  'Content-Type: text/plain'. "\n";<br>
                        $this->multipart.=  'Content-Transfer-Encoding: base64'. "\n\n";<br>
                        $this->multipart.= chunk_split(base64_encode($this->html_text)). "\n\n";<br>
<br>
// ttj added below <br>
                        $this->multipart.=  '--'.$thr_boundary. "\n";<br>
                        $this->multipart.=  'Content-Type: text/html'. "\n\n";<br>
                        $this->multipart.= $this->html. "\n\n";<br>
                        $this->multipart.=  '--'.$thr_boundary. "--\n\n";<br>
// ttj added above <br>
<br>
                        $this->multipart.=  '--'.$thr_boundary. "\n";<br>
                        $this->multipart.=  'Content-Type: text/html'. "\n";<br>
                        $this->multipart.=  'Content-Transfer-Encoding: base64'. "\n\n";<br>
                        $this->multipart.= chunk_split(base64_encode($this->html)). "\n\n";<br>
                        $this->multipart.=  '--'.$thr_boundary. "--\n\n";<br>
<br>
                        for($i=0; $i<count>html_images); $i++){<br>
                                $this->multipart.=  '--'.$sec_boundary. "\n";<br>
                                $this->build_html_image($i);<br>
                        }<br>
<br>
                        $this->multipart.=  "--".$sec_boundary. "--\n\n";<br>
                }<br>
        }<br>
/***************************************<br>
** Adds an image to the list of embedded<br>
** images.<br>
***************************************/ <br>
        function add_html_image($file, $name =  ', $c_type= 'application/octet-stream', $location= '){<br>
                $this->html_images[] = array(  'body' => $file,<br>
                                               'name' => $name,<br>
                                               'c_type' => $c_type,<br>
                           'location' => $location,<br>
                                               'cid' => md5(uniqid(time())) );<br>
        }<br>
<br>
<br>
/***************************************<br>
** Adds a file to the list of attachments.<br>
***************************************/ <br>
        function add_attachment($file, $name =  ', $c_type= 'application/octet-stream'){<br>
                $this->parts[] = array(  'body' => $file,<br>
                                         'name' => $name,<br>
                                         'c_type' => $c_type );<br>
        }<br>
<br>
/***************************************<br>
** Builds an embedded image part of an<br>
** html mail.<br>
***************************************/ <br>
        function build_html_image($i){<br>
                $this->multipart.=  'Content-Type: '.$this->html_images[$i][ 'c_type'];<br>
<br>
                if($this->html_images[$i][ 'name'] !=  ') $this->multipart .=  '; name="'.$this->html_images[$i][ 'name']. "\"\n";<br>
                else $this->multipart .=  "\n";<br>
<br>
                $this->multipart.=  'Content-Transfer-Encoding: base64'. "\n";<br>
        $this->multipart.=  'Content-Location:'.$this->html_images[$i][ 'location']. "\n";<br>
                $this->multipart.=  'Content-ID: html_images[$i][ 'cid']. ">\n\n";<br>
                $this->multipart.= chunk_split(base64_encode($this->html_images[$i][ 'body'])). "\n";<br>
        }<br>
<br>
/***************************************<br>
** Builds a single part of a multipart<br>
** message.<br>
***************************************/ <br>
        function build_part($i){<br>
                $message_part =  ';<br>
                $message_part.=  'Content-Type: '.$this->parts[$i][ 'c_type'];<br>
                if($this->parts[$i][ 'name'] !=  ')<br>
                        $message_part .=  '; name="'.$this->parts[$i][ 'name']. "\"\n";<br>
                else<br>
                        $message_part .=  "\n";<br>
<br>
                 // Determine content encoding. <br>
                if($this->parts[$i][ 'c_type'] ==  'text/plain'){<br>
                        $message_part.=  'Content-Transfer-Encoding: base64'. "\n\n";<br>
                        $message_part.= chunk_split(base64_encode($this->parts[$i][ 'body'])). "\n";<br>
                }else{<br>
                        $message_part.=  'Content-Transfer-Encoding: base64'. "\n";<br>
                        $message_part.=  'Content-Disposition: attachment; filename="'.$this->parts[$i][ 'name']. "\"\n\n";<br>
                        $message_part.= chunk_split(base64_encode($this->parts[$i][ 'body'])). "\n";<br>
                }<br>
<br>
                return $message_part;<br>
        }<br>
<br>
/***************************************<br>
** Builds the multipart message from the<br>
** list ($this->parts).<br>
***************************************/ <br>
        function build_message(){<br>
                $boundary =  '=_'.md5(uniqid(time()));<br>
<br>
                $this->headers.=  "MIME-Version: 1.0\n";<br>
                $this->headers.=  "Content-Type: multipart/mixed;".chr(10).chr(9). "boundary=\"".$boundary. "\"\n";<br>
                $this->multipart =  ';<br>
//                $this->multipart.= "This is a MIME encoded message.\nCreated by html_mime_mail.class.\nSee http://www.heyes-computing.net/scripts/ for a copy.\n\n"; <br>
<br>
                if(isset($this->do_html) AND $this->do_html == 1) $this->build_html($boundary);<br>
                if(isset($this->body) AND $this->body !=  ') $this->parts[] = array( 'body' => $this->body,  'name' =>  ',  'c_type' =>  'text/plain');<br>
<br>
                for($i=(count($this->parts)-1); $i>=0; $i--){<br>
                        $this->multipart.=  '--'.$boundary. "\n".$this->build_part($i);<br>
                }<br>
<br>
                $this->mime = $this->multipart. "--".$boundary. "--\n";<br>
        }<br>
<br>
/***************************************<br>
** Sends the mail.<br>
***************************************/ <br>
        function send($to_name, $to_addr, $from_name, $from_addr, $subject =  ', $headers =  '){<br>
<br>
                if($to_name !=  ') $to =  '"'.$to_name. '" ';<br>
                else $to = $to_addr;<br>
<br>
                if($from_name !=  ') $from =  '"'.$from_name. '" ';<br>
                else $from = $from_addr;<br>
<br>
                mail($to, $subject, $this->mime,  'From: '.$from. "\n".$headers. "\n".$this->headers);<br>
        }<br>
<br>
/***************************************<br>
** Use this method to deliver using direct<br>
** smtp connection. Relies upon Manuel Lemos'<br>
** smtp mail delivery class available at:<br>
** http://phpclasses.upperdesign.com<br>
**<br>
** void smtp_send( string *Name* of smtp object,<br>
**                 string From address,<br>
**                 array  To addresses,<br>
**                 string Subject)<br>
***************************************/ <br>
        function smtp_send($smtp_obj, $from_addr, $to_addr, $subject){<br>
                global $$smtp_obj;<br>
                $smtp_obj = $$smtp_obj;<br>
<br>
                $this->headers .=  'From: '.$from_addr. "\n";<br>
                $this->headers .=  'Subject: '.$subject. "\n";<br>
<br>
                if(substr($this->headers, -2) ==  "\n") $this->headers = substr($this->headers,0,-2);<br>
                $this->headers = explode( "\n", $this->headers);<br>
<br>
                $smtp_obj->sendmessage($from_addr, $to_addr, $this->headers, $this->mime);<br>
        }<br>
<br>
}  // End of class. <br>
?><br>

                
					
		
		
		
    </count></count></sascha></tobias></richard.heyes>
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
The Continued Use of PHP: Reasons for Its EnduranceThe Continued Use of PHP: Reasons for Its EnduranceApr 19, 2025 am 12:23 AM

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python: Exploring Their Similarities and DifferencesPHP and Python: Exploring Their Similarities and DifferencesApr 19, 2025 am 12:21 AM

PHP and Python are both high-level programming languages ​​that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP and Python: Different Paradigms ExplainedPHP and Python: Different Paradigms ExplainedApr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python: A Deep Dive into Their HistoryPHP and Python: A Deep Dive into Their HistoryApr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Choosing Between PHP and Python: A GuideChoosing Between PHP and Python: A GuideApr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP and Frameworks: Modernizing the LanguagePHP and Frameworks: Modernizing the LanguageApr 18, 2025 am 12:14 AM

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHP's Impact: Web Development and BeyondPHP's Impact: Web Development and BeyondApr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

How does PHP type hinting work, including scalar types, return types, union types, and nullable types?How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool