⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 class.phpmailer.php

📁 在综合英文版XOOPS 2.09, 2.091, 2.092 的基础上正式发布XOOPS 2.09中文版 XOOPS 2.09x 版主要是PHP5升级、bug修正和安全补正: 1 全面兼容PHP 5.
💻 PHP
📖 第 1 页 / 共 4 页
字号:
//        $encoded = $this->word_wrap($encoded, $maxlen, true);//        $encoded = str_replace("=".$this->LE, "\n", trim($encoded));//      }      $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);      $encoded = trim(str_replace("\n", $this->LE, $encoded));            return($encoded);    }        /**     * Encode string to quoted-printable.  Returns a string.     * @access private     * @return string     */    function encode_qp ($str) {        $encoded = $this->fix_eol($str);        if (substr($encoded, -2) != $this->LE)            $encoded .= $this->LE;        // Replace every high ascii, control and = characters        $encoded = preg_replace('/([\000-\010\013\014\016-\037\075\177-\377])/e',                  "'='.sprintf('%02X', ord('\\1'))", $encoded);        // Replace every spaces and tabs when it's the last character on a line        $encoded = preg_replace("/([\011\040])".$this->LE."/e",                  "'='.sprintf('%02X', ord('\\1')).'".$this->LE."'", $encoded);        // Maximum line length of 76 characters before CRLF (74 + space + '=')        $encoded = $this->word_wrap($encoded, 74, true);        return $encoded;    }    /**     * Encode string to q encoding.  Returns a string.     * @access private     * @return string     */    function encode_q ($str, $position = 'text') {        // There should not be any EOL in the string        $encoded = preg_replace("[\r\n]", "", $str);        switch (strtolower($position)) {          case 'phrase':            $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);            break;          case 'comment':            $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);            // Fall-through          case 'text':          default:            // Replace every high ascii, control =, ? and _ characters            $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',                  "'='.sprintf('%02X', ord('\\1'))", $encoded);            break;        }                // Replace every spaces to _ (more readable than =20)        $encoded = str_replace(" ", "_", $encoded);        return $encoded;    }    /**     * Adds a string or binary attachment (non-filesystem) to the list.     * This method can be used to attach ascii or binary data,     * such as a BLOB record from a database.     * @access public     * @return void     */    function AddStringAttachment($string, $filename, $encoding = "base64", $type = "application/octet-stream") {        // Append to $attachment array        $cur = count($this->attachment);        $this->attachment[$cur][0] = $string;        $this->attachment[$cur][1] = $filename;        $this->attachment[$cur][2] = $filename;        $this->attachment[$cur][3] = $encoding;        $this->attachment[$cur][4] = $type;        $this->attachment[$cur][5] = true; // isString        $this->attachment[$cur][6] = "attachment";        $this->attachment[$cur][7] = 0;    }        /**     * Adds an embedded attachment.  This can include images, sounds, and      * just about any other document.       * @param cid this is the Content Id of the attachment.  Use this to identify     *        the Id for accessing the image in an HTML form.     * @access public     * @return bool     */    function AddEmbeddedImage($path, $cid, $name = "", $encoding = "base64", $type = "application/octet-stream") {            if(!@is_file($path))        {            $this->error_handler(sprintf("Could not access [%s] file", $path));            return false;        }        $filename = basename($path);        if($name == "")            $name = $filename;        // Append to $attachment array        $cur = count($this->attachment);        $this->attachment[$cur][0] = $path;        $this->attachment[$cur][1] = $filename;        $this->attachment[$cur][2] = $name;        $this->attachment[$cur][3] = $encoding;        $this->attachment[$cur][4] = $type;        $this->attachment[$cur][5] = false; // isStringAttachment        $this->attachment[$cur][6] = "inline";        $this->attachment[$cur][7] = $cid;            return true;    }        /**     * Returns the number of embedded images in an email.     * @access private     * @return int     */    function EmbeddedImageCount() {        $ret = 0;        for($i = 0; $i < count($this->attachment); $i++)        {            if($this->attachment[$i][6] == "inline")                $ret++;        }                return $ret;    }    /////////////////////////////////////////////////    // MESSAGE RESET METHODS    /////////////////////////////////////////////////    /**     * Clears all recipients assigned in the TO array.  Returns void.     * @access public     * @return void     */    function ClearAddresses() {        $this->to = array();    }    /**     * Clears all recipients assigned in the CC array.  Returns void.     * @access public     * @return void     */    function ClearCCs() {        $this->cc = array();    }    /**     * Clears all recipients assigned in the BCC array.  Returns void.     * @access public     * @return void     */    function ClearBCCs() {        $this->bcc = array();    }    /**     * Clears all recipients assigned in the ReplyTo array.  Returns void.     * @access public     * @return void     */    function ClearReplyTos() {        $this->ReplyTo = array();    }    /**     * Clears all recipients assigned in the TO, CC and BCC     * array.  Returns void.     * @access public     * @return void     */    function ClearAllRecipients() {        $this->to = array();        $this->cc = array();        $this->bcc = array();    }    /**     * Clears all previously set filesystem, string, and binary     * attachments.  Returns void.     * @access public     * @return void     */    function ClearAttachments() {        $this->attachment = array();    }    /**     * Clears all custom headers.  Returns void.     * @access public     * @return void     */    function ClearCustomHeaders() {        $this->CustomHeader = array();    }    /////////////////////////////////////////////////    // MISCELLANEOUS METHODS    /////////////////////////////////////////////////    /**     * Adds the error message to the error container.     * Returns void.     * @access private     * @return void     */    function error_handler($msg) {        $this->ErrorInfo = $msg;    }    /**     * Returns the proper RFC 822 formatted date. Returns string.     * @access private     * @return string     */    function rfc_date() {        $tz = date("Z");        $tzs = ($tz < 0) ? "-" : "+";        $tz = abs($tz);        $tz = ($tz/3600)*100 + ($tz%3600)/60;        $date = sprintf("%s %s%04d", date("D, j M Y H:i:s"), $tzs, $tz);        return $date;    }    /**     * Returns received header for message tracing. Returns string.     * @access private     * @return string     */    function received() {        // Check for vars because they might not exist.  Possibly        // write a small retrieval function (that mailer can use too!)        if ($this->get_server_var('SERVER_NAME') != '')	{            $protocol = ($this->get_server_var('HTTPS') == 'on') ? 'HTTPS' : 'HTTP';	    $remote = $this->get_server_var('REMOTE_HOST');	    if ($remote == '')	        $remote = 'phpmailer';	    $remote .= ' (['.$this->get_server_var('REMOTE_ADDR').'])';	}        else	{            $protocol = 'local';	    $remote = $this->get_server_var('USER');	    if ($remote == '')	        $remote = 'phpmailer';	}        $str = sprintf("Received: from %s %s\tby %s " .               "with %s (phpmailer);%s\t%s%s",	       $remote,	       $this->LE,               $this->get_server_hostname(),	       $protocol,               $this->LE,               $this->rfc_date(),               $this->LE);        return $str;    }        /**     * Returns the appropriate server variable.  Should work with both      * PHP 4.1.0+ as well as older versions.  Returns an empty string      * if nothing is found.     * @access private     * @return mixed     */    function get_server_var($varName) {        global $HTTP_SERVER_VARS;        global $HTTP_ENV_VARS;        if(!isset($_SERVER))        {            $_SERVER = $HTTP_SERVER_VARS;            if(!isset($_SERVER["REMOTE_ADDR"]))                $_SERVER = $HTTP_ENV_VARS; // must be Apache        }                if(isset($_SERVER[$varName]))            return $_SERVER[$varName];        else            return "";    }    /**     * Returns the server hostname or 'localhost.localdomain' if unknown.     * @access private     * @return string     */    function get_server_hostname() {        if ($this->Hostname != '')	    return $this->Hostname;	elseif ($this->get_server_var('SERVER_NAME') != '')	    return $this->get_server_var('SERVER_NAME');	else	    return 'localhost.localdomain';    }    /**     * Changes every end of line from CR or LF to CRLF.  Returns string.     * @access private     * @return string     */    function fix_eol($str) {        $str = str_replace("\r\n", "\n", $str);        $str = str_replace("\r", "\n", $str);        $str = str_replace("\n", $this->LE, $str);        return $str;    }    /**     * Adds a custom header.  Returns void.     * @access public     * @return void     */    function AddCustomHeader($custom_header) {        // Append to $custom_header array        $this->CustomHeader[] = explode(":", $custom_header, 2);    }    /**     * Adds all the Microsoft message headers.  Returns string.     * @access private     * @return string     */    function AddMSMailHeaders() {        $MSHeader = "";        if($this->Priority == 1)            $MSPriority = "High";        elseif($this->Priority == 5)            $MSPriority = "Low";        else            $MSPriority = "Medium";        $MSHeader .= sprintf("X-MSMail-Priority: %s%s", $MSPriority, $this->LE);        $MSHeader .= sprintf("Importance: %s%s", $MSPriority, $this->LE);        return($MSHeader);    }}/** * Boundary - MIME message boundary class * @author Brent R. Matzelle */class Boundary{    /**     * Sets the boundary ID.     * @access private     * @var string     */    var $ID = 0;    /**     * Sets the boundary Content Type.     * @access public     * @var string     */    var $ContentType = "text/plain";    /**     * Sets the Encoding.     * @access public     * @var string     */    var $Encoding = "";    /**     * Sets an attachment disposition.     * @access public     * @var string     */    var $Disposition = "";    /**     * Sets an attachment file name.     * @access public     * @var string     */    var $FileName = "";        /**     * Sets the Char set.     * @access public     * @var string     */    var $CharSet = "";        /**     *  Sets the line endings of the message.  Default is "\n";     *  @access public     *  @var string     */    var $LE           = "\n";        /**     * Main constructor.     */    function Boundary($boundary_id) {        $this->ID = $boundary_id;    }        /**     * Returns the source of the boundary.     * @access public     * @return string     */    function GetSource($bLineEnding = true) {        $mime = array();        $mime[] = sprintf("--%s%s", $this->ID, $this->LE);        $mime[] = sprintf("Content-Type: %s; charset = \"%s\"%s",                           $this->ContentType, $this->CharSet, $this->LE);        $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $this->Encoding,                           $this->LE);                if(strlen($this->Disposition) > 0)        {            $mime[] = sprintf("Content-Disposition: %s;");            if(strlen($this->FileName) > 0)                $mime[] = sprinf("filename=\"%s\"", $this->FileName);        }                if($bLineEnding)            $mime[] = $this->LE;        return join("", $mime);    }}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -