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

📄 class.phpmailer.php

📁 在综合英文版XOOPS 2.09, 2.091, 2.092 的基础上正式发布XOOPS 2.09中文版 XOOPS 2.09x 版主要是PHP5升级、bug修正和安全补正: 1 全面兼容PHP 5.
💻 PHP
📖 第 1 页 / 共 4 页
字号:
<?php////////////////////////////////////////////////////// phpmailer - PHP email class//// Version 1.65, Created 08/09/2002//// Class for sending email using either// sendmail, PHP mail(), or SMTP.  Methods are// based upon the standard AspEmail(tm) classes.//// Author: Brent R. Matzelle <bmatzelle@yahoo.com>//// License: LGPL, see LICENSE/////////////////////////////////////////////////////** * phpmailer - PHP email transport class * @author Brent R. Matzelle */class phpmailer{    /////////////////////////////////////////////////    // PUBLIC VARIABLES    /////////////////////////////////////////////////    /**     * Email priority (1 = High, 3 = Normal, 5 = low).     * @access public     * @var int     */    var $Priority          = 3;    /**     * Sets the CharSet of the message.     * @access public     * @var string     */    var $CharSet           = "iso-8859-1";    /**     * Sets the Content-type of the message.     * @access public     * @var string     */    var $ContentType        = "text/plain";    /**     * Sets the Encoding of the message. Options for this are "8bit",     * "7bit", "binary", "base64", and "quoted-printable".     * @access public     * @var string     */    var $Encoding          = "8bit";    /**     * Holds the most recent mailer error message.     * @access public     * @var string     */    var $ErrorInfo         = "";    /**     * Sets the From email address for the message.     * @access public     * @var string     */    var $From               = "root@localhost";    /**     * Sets the From name of the message.     * @access public     * @var string     */    var $FromName           = "Root User";    /**     * Sets the Sender email of the message. If not empty, will be sent via -f to sendmail     * or as 'MAIL FROM' in smtp mode.     * @access public     * @var string     */    var $Sender            = "";    /**     * Sets the Subject of the message.     * @access public     * @var string     */    var $Subject           = "";    /**     * Sets the Body of the message.  This can be either an HTML or text body.     * If HTML then run IsHTML(true).     * @access public     * @var string     */    var $Body               = "";    /**     * Sets the text-only body of the message.  This automatically sets the     * email to multipart/alternative.  This body can be read by mail     * clients that do not have HTML email capability such as mutt. Clients     * that can read HTML will view the normal Body.     * @access public     * @var string     */    var $AltBody           = "";    /**     * Sets word wrapping on the body of the message to a given number of      * characters.     * @access public     * @var int     */    var $WordWrap          = 0;    /**     * Method to send mail: ("mail", "sendmail", or "smtp").     * @access public     * @var string     */    var $Mailer            = "mail";    /**     * Sets the path of the sendmail program.     * @access public     * @var string     */    var $Sendmail          = "/usr/sbin/sendmail";    /**     *  Turns Microsoft mail client headers on and off.  Useful mostly     *  for older clients.     *  @access public     *  @var bool     */    var $UseMSMailHeaders = false;        /**     * Path to phpmailer plugins.  This is now only useful if the SMTP class      * is in a different directory than the PHP include path.       * @access public     * @var string     */    var $PluginDir         = "";    /**     *  Holds phpmailer version.     *  @access public     *  @var string     */    var $Version           = "1.65";    /**     * Sets the email address that a reading confirmation will be sent.     * @access public     * @var string     */    var $ConfirmReadingTo  = "";    /**     *  Sets the line endings of the message.     *  @access public     *  @var string     */    var $LE           = "\n";    /**     *  Sets the hostname to use in Message-Id and Received headers     *  and as default HELO string. If empty, the value returned     *  by SERVER_NAME is used or 'localhost.localdomain'.     *  @access public     *  @var string     */    var $Hostname          = "";    /////////////////////////////////////////////////    // SMTP VARIABLES    /////////////////////////////////////////////////    /**     *  Sets the SMTP hosts.  All hosts must be separated by a     *  semicolon.  You can also specify a different port     *  for each host by using this format: [hostname:port]     *  (e.g. "smtp1.example.com:25;smtp2.example.com").     *  Hosts will be tried in order.     *  @access public     *  @var string     */    var $Host        = "localhost";    /**     *  Sets the default SMTP server port.     *  @access public     *  @var int     */    var $Port        = 25;    /**     *  Sets the SMTP HELO of the message (Default is $Hostname).     *  @access public     *  @var string     */    var $Helo        = "";    /**     *  Sets SMTP authentication. Utilizes the Username and Password variables.     *  @access public     *  @var bool     */    var $SMTPAuth     = false;    /**     *  Sets SMTP username.     *  @access public     *  @var string     */    var $Username     = "";    /**     *  Sets SMTP password.     *  @access public     *  @var string     */    var $Password     = "";    /**     *  Sets the SMTP server timeout in seconds. This function will not      *  work with the win32 version.     *  @access public     *  @var int     */    var $Timeout      = 10;    /**     *  Sets SMTP class debugging on or off.     *  @access public     *  @var bool     */    var $SMTPDebug    = false;    /////////////////////////////////////////////////    // PRIVATE VARIABLES    /////////////////////////////////////////////////    /**     *  Holds all "To" addresses.     *  @access private     *  @var array     */    var $to              = array();    /**     *  Holds all "CC" addresses.     *  @access private     *  @var array     */    var $cc              = array();    /**     *  Holds all "BCC" addresses.     *  @access private     *  @var array     */    var $bcc             = array();    /**     *  Holds all "Reply-To" addresses.     *  @var array     */    var $ReplyTo         = array();    /**     *  Holds all string and binary attachments.     *  @access private     *  @var array     */    var $attachment      = array();    /**     *  Holds all custom headers.     *  @var array     */    var $CustomHeader    = array();    /**     *  Holds the type of the message.     *  @var string     */    var $message_type    = "";    /**     *  Holds the message boundaries.     *  @access private     *  @var string array     */    var $boundary        = array();    /////////////////////////////////////////////////    // VARIABLE METHODS    /////////////////////////////////////////////////    /**     * Sets message type to HTML.  Returns void.     * @access public     * @return void     */    function IsHTML($bool) {        if($bool == true)            $this->ContentType = "text/html";        else            $this->ContentType = "text/plain";    }    /**     * Sets Mailer to send message using SMTP.     * Returns void.     * @access public     * @return void     */    function IsSMTP() {        $this->Mailer = "smtp";    }    /**     * Sets Mailer to send message using PHP mail() function.     * Returns void.     * @access public     * @return void     */    function IsMail() {        $this->Mailer = "mail";    }    /**     * Sets Mailer to send message using the $Sendmail program.     * Returns void.     * @access public     * @return void     */    function IsSendmail() {        $this->Mailer = "sendmail";    }    /**     * Sets Mailer to send message using the qmail MTA.  Returns void.     * @access public     * @return void     */    function IsQmail() {        //$this->Sendmail = "/var/qmail/bin/qmail-inject";        $this->Sendmail = "/var/qmail/bin/sendmail";        $this->Mailer = "sendmail";    }    /////////////////////////////////////////////////    // RECIPIENT METHODS    /////////////////////////////////////////////////    /**     * Adds a "To" address.  Returns void.     * @access public     * @return void     */    function AddAddress($address, $name = "") {        $cur = count($this->to);        $this->to[$cur][0] = trim($address);        $this->to[$cur][1] = $name;    }    /**     * Adds a "Cc" address. Note: this function works     * with the SMTP mailer on win32, not with the "mail"     * mailer.  This is a PHP bug that has been submitted     * on http://bugs.php.net. The *NIX version of PHP     * functions correctly. Returns void.     * @access public     * @return void    */    function AddCC($address, $name = "") {        $cur = count($this->cc);        $this->cc[$cur][0] = trim($address);        $this->cc[$cur][1] = $name;    }    /**     * Adds a "Bcc" address. Note: this function works     * with the SMTP mailer on win32, not with the "mail"     * mailer.  This is a PHP bug that has been submitted     * on http://bugs.php.net. The *NIX version of PHP     * functions correctly.     * Returns void.     * @access public     * @return void     */    function AddBCC($address, $name = "") {        $cur = count($this->bcc);        $this->bcc[$cur][0] = trim($address);        $this->bcc[$cur][1] = $name;    }    /**     * Adds a "Reply-to" address.  Returns void.     * @access public     * @return void     */    function AddReplyTo($address, $name = "") {        $cur = count($this->ReplyTo);        $this->ReplyTo[$cur][0] = trim($address);        $this->ReplyTo[$cur][1] = $name;    }    /////////////////////////////////////////////////    // MAIL SENDING METHODS    /////////////////////////////////////////////////    /**     * Creates message and assigns Mailer. If the message is     * not sent successfully then it returns false.  Use the ErrorInfo     * variable to view description of the error.  Returns bool.     * @access public     * @return bool     */    function Send() {        $header = "";        $body = "";        if((count($this->to) + count($this->cc) + count($this->bcc)) < 1)        {            $this->error_handler("You must provide at least one recipient email address");            return false;        }        // Set whether the message is multipart/alternative        if(!empty($this->AltBody))            $this->ContentType = "multipart/alternative";        // Attach sender information & date        $header = $this->received();        $header .= sprintf("Date: %s%s", $this->rfc_date(), $this->LE);        $header .= $this->create_header();

⌨️ 快捷键说明

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