Send MIME message class _php tutorial

Source: Internet
Author: User
If it does not include the file: $mail = new Html_mime_mail (); $html = "HTML content"; $mail->add_html ($html, $text); $mail->build_message (); $mail->send (recipient, mail, sender, email, title, extra header); If it contains a file: $url = "www.cuti.com.my/AD/"; A file? FONT color= "#007700";}? The FONT color= "#007700", and the end has a diagonal line $path = "/mail/ad/"; The path ends with a diagonal $filename 1 = a.jpg; $backgrnd 1 = fread ($fp = fopen ($path. $filename 1, R), FileSize ($path. $filename 1)); Fclose ($FP); ... According to this type of push ... $filename 6 = f.gif; $backgrnd 6 = fread ($fp = fopen ($path. $filename 6, R), FileSize ($path. $filename 6)); Fclose ($FP); $mail->add_html_image ($backgrnd 1, $filename 1,image/jpeg,http://. $url. $filename 1); ... According to this type of push ... $mail->add_html_image ($backgrnd 6, $filename 6,image/gif,http://. $url. $filename 6); $mail = new Html_mime_mail (); $html = "HTML contains image content"; $mail->add_html ($html, $text); $mail->build_message (); $mail->send (recipient, mail, sender, email, title, extra header); "; } /*************************************** * * Title ...: HTML Mime Mail class * * Version ....: 1.* * * Author ...: Richard heyes * * Filename ...: html_mime_mail.class * * Last changed ...: 25/06/2000 * * Notes ...: Based upon Mime_mail.class * by Tobias Ratschiller * * and Sascha Schumann . * *-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 EQU Al sign on the boundary line. Thanks to * * Peter Holm for notifying me. * *-Fixed bug; $html _images is tested to is an array or not * * but is set to is 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 $ht ml 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-ids. /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 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 (count ($this->html_images) = = 0) {$this->multipart.=--. $orig _boundary. ""; $this->multipart.= content-type:multipart/alternative;. Chr (9). Boundary= ". $sec _boundary. """; TTJ added below $this->multipart.=--. $thr _boundary. ""; $this->multipart.= Content-type:text/plain. ""; $this->multipart.= $this->html_text. ""; $this->multipart.=--. $thr _boundary. "--"; Ttj added above $this->multipart.=--. $sec _boundary. ""; $this->multipart.= Content-type:text/plain. ""; $this->multipart.= content-transfer-encoding:base64. ""; $this->multipart.= chunk_split ($ base64_encode ($This->html_text)). ""; TTJ added below $this->multipart.=--. $thr _boundary. ""; $this->multipart.= content-type:text/html. ""; $this->multipart.= $this->html. ""; $this->multipart.=--. $thr _boundary. "--"; Ttj added above $this->multipart.=--. $sec _boundary. ""; $this->multipart.= content-type:text/html. ""; $this->multipart.= content-transfer-encoding:base64. ""; $this->multipart.= chunk_split (Base64_encode ($this->html)). ""; $this->multipart.=--. $sec _boundary. "--"; }else{$this->multipart.=--. $orig _boundary. ""; $this->multipart.= content-type:multipart/related;. Chr (9). Boundary= ". $sec _boundary. """; $this->multipart.=--. $sec _boundary. ""; $this->multipart.= content-type:multipart/alternative;. Chr (9). Boundary= ". $thr _boundary. """; $this->multipart.=--. $thr _boundary. ""; $this->multipart.= Content-type:text/plain. ""; $this->multipart.= content-transfer-encoding:base64. ""; $this->multipart.= Chunk_split (Base64_encode ($this->html_text)). ""; TTJ added below $this->multipart.=--. $thr _boundary. ""; $this->multipart.= content-type:text/html. ""; $this->multipart.= $this->html. ""; $this->multipart.=--. $thr _boundary. "--"; Ttj added above $this->multipart.=--. $thr _boundary. ""; $this->multipart.= content-type:text/html. ""; $this->multipart.= content-transfer-encoding:base64. ""; $this->multipart.= chunk_split (Base64_encode ($this->html)). ""; $this->multipart.=--. $thr _boundary. "--"; for ($i =0; $i Html_images); $i + +) {$this->multipart.=--. $sec _boundary. ""; $this->build_html_image ($i); } $this->multipart.= "--". $sec _boundary. "--"; }}/*************************************** * * Adds an image to the list of embedded * * images. /function Add_html_image ($file, $name =, $c _type= application/octet-stream, $ location=) {$this->html_images[] = Array (BODY = $file, name = $name, C_type = $c _type, location + $lo cation, CID = MD5 (Uniqid (Time ())); }/*************************************** * * Adds a file to the list of attachments. /function Add_attachment ($file, $name =, $c _type= application/octet-stream) { $this->parts[] = Array (BODY = $file, name = $name, C_type = $c _type); }/*************************************** * * Builds an embedded image part of an * * HTML mail. /function Build_html_image ($i) {$this->multipart.= content-type:. $this->html_images[$i] [c_type]; if ($this->html_images[$i [name]! =) $this->multipart. =; Name= ". $this->html_images[$i [name]. """; else $this->multipart. = ""; $this->multipart.= content-transfer-encoding:base64. ""; $this->multipart.= content-location:. $this->html_images[$i] [location]. ""; $this->multipart.= Content-id: <. $this->html_images[$i] [CID]. ">"; $this->multipart.= chunk_split (Base64_encode ($this->html_images[$i] [body]). ""; } /*************************************** * * Builds a single part of a multipart * * message. /function Build_part ($i) {$message _part =; $message _par

http://www.bkjia.com/PHPjc/531886.html www.bkjia.com true http://www.bkjia.com/PHPjc/531886.html techarticle if not included: $mail = new Html_mime_mail (), $html =html, $mail->add_html ($html, $text); $mail->build_message (); $ Mail->send (recipient, email, sender, e-mail, logo ...)

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.