SyntaxHighlighter. all (); news & nbsp; | & nbsp; Security & nbsp; | & nbsp; Forum & nbsp; | & nbsp; download & nb
Mail_header = "MIME-Version: 1.0 Content-Type: multipart/mixed; boundary =" $ this-> boundary0 "This is a multi-part message in MIME format. -- $ this-> boundary0 Content-Type: multipart/related; boundary = "$ this-> boundary1 "; type = "multipart/alternative" -- $ this-> boundary1 Content-Type: multipart/alternative; boundary = "$ this-> boundary2" ";} function str_row ($ str, $ n) // split the string into n rows. in OUTLOOK, it seems that BASE64 must be cut into <77 characters/line before {$ I = 0; if ($ n <1) return $ str; while ($ I $ N) {$ new_str. = substr ($ str, $ I, $ n ). chr (13 ). chr (10); $ I + = $ n;} else {$ new_str. = $ str; $ I = strlen ($ str) ;}return $ new_str;} function loadfromfile ($ filename) // Read and encode the file {$ fp = fopen ($ filename, "rb"); $ c = fread ($ fp, filesize ($ filename )); fclose ($ fp); return $ this-> str_row (base64_encode ($ c), 77);} function file_header ($ filename) // give the file header {switch (substr ($ filename, strlen ($ filename)-3) {case "gif": return "Content-Type: image/gif name = "$ filename" "; break; case" jpg "; return" Content-Type: image/jpeg name = "$ filename" "; break; case "txt"; return "Content-Type: text/plain name =" $ filename ""; break; default: return "Content-Type: application/octetstream name = "$ filename" ";}} function mail_body ($ str) // HTML section {$ this-> body. = "--". $ this-> boundary2. "Content-Type: text/html; charset =" gb2312 "". $ str. "--". $ this-> boundary2. "--";} function mail_picture ($ filename) // The Attachment image, which must be added here in HTML, otherwise, the {if ($ filename = null) {$ this-> body cannot be displayed locally. = "--". $ this-> boundary1. "--" ;}for ($ I = 0; $ I Body = str_replace ($ filename [$ I], "cid: $ cid", $ this-> body); $ this-> body. = "--". $ this-> boundary1. ""; $ this-> body. = $ this-> file_header ($ filename [$ I]). "Content-Transfer-Encoding: base64"; $ this-> body. = "Content-ID: <$ cid>"; $ this-> body. = $ this-> loadfromfile ($ filename [$ I]);} $ this-> body. = "--". $ this-> boundary1. "--";} function mail_attachment ($ filename) // attachment {for ($ I = 0; $ I Body. = "--". $ this-> boundary0." "; $ this-> body. = $ this-> file_header ($ filename [$ I]). "Content-Transfer-Encoding: base64Content-Disposition: attachment; filename =" $ filename [$ I] ""; $ this-> body. = $ this-> loadfromfile ($ filename [$ I]);} $ this-> body. = "--". $ this-> boundary0." -- ";} function send_mail ($ to, $ subject, $ from) // send {mail ($ to, $ subject, $ this-> body, "From :". $ from. "". $ this-> get_mail_header () ;};/* $ s = new m Ime_mail; // The Call Format is $ s-> mail_body ("heheehe"); $ s-> mail_picture (array ("test.gif", "Thumb1.jpg ")); // If not, write mail_picture (null); the following is $ s-> mail_attachment (array ("MIME_MAIL.PHP", "Thumb1.jpg", "newProject.rar", "session.zip ")); $ s-> send_mail ("wan_dou@wenwenweb.com", "test", "zhangxw@online.sh.cn"); */?>