A mime mail class is found. _ PHP Tutorial

Source: Internet
Author: User
A mime mail class is found .. Partsarray (); $ this-to; $ this-from; $ this-subject; $ this-body; $ this-headers;} ** voidadd_attachment (stringmessage, * [stringname], * [stringctype]) * Parts = array (); $ this-> to = ""; $ this-> from = ""; $ this-> subject = ""; $ this-> body = ""; $ this-> headers = "";}/** void add_attachment (string message, * [string name], * [string ctype]) * Add an attachment to the receiver object */function add_attachment ($ message, $ name = "", $ ctype = "application/octet-stream ") {$ this-> parts [] = array ("ctype" => $ ctype, "message" => $ message, "encode" => $ encode, "name" => $ name );} /** Void build_message (array part) * create the information part of the multipart Upload File */function build_message ($ part) {$ message = $ part ["message"]; $ message = chunk_split (base64_encode ($ message); $ encoding = "base64"; return "Content-Type :". $ part ["ctype"]. ($ part ["name"]? "; Name = "". $ part ["name"]. """:""). "Content-Transfer-Encoding: $ encoding $ message";}/** void build_multipart () * Create a multipart Upload File */function build_multipart () {$ boundary = "B ". md5 (uniqid (time (); $ multipart = "Content-Type: multipart/mixed ;". "boundary = $ boundary ". "This is a MIME encoded message. -- $ boundary "; for ($ I = sizeof ($ this-> parts)-1; $ I >=0; $ I --) {$ multipart. = "". $ t His-> build_message ($ this-> parts [$ I]). "-- $ boundary";} return $ multipart. "--";}/** string get_mail () * Restore the assembled parts */function get_mail ($ complete = true) {$ mime = ""; if (! Empty ($ this-> from) $ mime. = "From:". $ this-> from. ""; if (! Empty ($ this-> headers) $ mime. = $ this-> headers. ""; if ($ complete) {if (! Empty ($ this-> to) $ mime. = "To: $ this-> to"; if (! Empty ($ this-> subject) $ mime. = "Subject: $ this-> subject";} if (! Empty ($ this-> body) $ this-> add_attachment ($ this-> body, "", "text/plain"); $ mime. = "maid: 1.0 ". $ this-> build_multipart (); return $ mime;}/** void send () * send this letter (the last called Letter) */function send () {$ mime = $ this-> get_mail (false); mail ($ this-> to, $ this-> subject ,"", $ mime) ;}// do you want to end with a different type?>

Http://www.bkjia.com/PHPjc/531858.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/531858.htmlTechArticleparts = array (); $ this-> to =; $ this-> from =; $ this-> subject =; $ this-> body =; $ this-> headers =;}/** void add_attachment (string message, * [string name], * [string ctype]) *...

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.