class.phpmailer.php

来自「asterisk用 的voip记费软件」· PHP 代码 · 共 1,389 行 · 第 1/3 页

PHP
1,389
字号
<?php////////////////////////////////////////////////////// phpmailer - PHP email classclass phpmailer{    /////////////////////////////////////////////////    // PUBLIC VARIABLES    /////////////////////////////////////////////////    /**     * Email priority (1 = High, 3 = Normal, 5 = low). Default value is 3.     * @public     * @type int     */    var $Priority          = 3;    /**     * Sets the CharSet of the message. Default value is "iso-8859-1".     * @public     * @type string     */    //var $CharSet           = "iso-8859-1";	var $CharSet           = "UTF-8";	    /**     * Sets the CharSet of the message. Default value is "iso-8859-1".     * @public     * @type string     */    var $Subject_CharSet   = 0;    /**     * Sets the Content-type of the message. Default value is "text/plain".     * @public     * @type string     */    var $ContentType        = "text/plain";    /**     * Sets the Encoding of the message. Options for this are "8bit" (default),     * "7bit", "binary", "base64", and "quoted-printable".     * @public     * @type string     */    var $Encoding          = "8bit";    /**     * Holds the most recent mailer error message. Default value is "".     * @public     * @type string     */    var $ErrorInfo        = "";    /**     * Sets the From email address for the message. Default value is "root@localhost".     * @public     * @type string     */    var $From               = "";    /**     * Sets the From name of the message. Default value is "Root User".     * @public     * @type string     */    var $FromName          = "";    /**     * Sets the Sender email of the message. If not empty, will be sent via -f to sendmail     * or as 'MAIL FROM' in smtp mode. Default value is "".     * @public     * @type string     */    var $Sender            = ""; //server01.us2.egwn.net	// mailing.electronic-group.com    /**     * Sets the Subject of the message. Default value is "".     * @public     * @type string     */    var $Subject           = "";    /**     * Sets the Body of the message.  This can be either an HTML or text body.     * If HTML then run IsHTML(true). Default value is "".     * @public     * @type 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.     * Default value is "".     * @public     * @type string     */    var $AltBody           = "";    /**     * Sets word wrapping on the message. Default value is 0 (off).     * @public     * @type int     */    var $WordWrap          = 0;    /**     * Method to send mail: ("mail", "sendmail", or "smtp").     * Default value is "mail".     * @public     * @type string     */    var $Mailer            = "mail";    /**     * Sets the path of the sendmail program. Default value is     * "/usr/sbin/sendmail".     * @public     * @type string     */    var $Sendmail          = "/usr/sbin/sendmail";    /**     *  Turns Microsoft mail client headers on and off.  Useful mostly     *  for older clients. Default value is false (off).     *  @public     *  @type bool     */    var $UseMSMailHeaders = false;    /**     *  Holds phpmailer version.     *  @public     *  @type string     */    var $Version           = "3.01";    /////////////////////////////////////////////////    // 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.domain.com:25;smtp2.domain.com").     *  Hosts will be tried in order.     *  Default value is "localhost".     *  @public     *  @type string     */    var $Host       = "localhost";		    	    /** FORGET THAT IS SHITTTTTTTTTTTT     * Number of SMTP server	 * this value will be automaticly update     * @public     * @type int     */    var $Nb_SMTP_Server          = 1;    /**     * Number of the curent SMTP server 	 * A rotate system increment this number after each sending     * @public     * @type int     */    var $Curent_SMTP_Server      = -1;	/**     * Number of the try to send by SMTP     * @public     * @type int     */	var $nb_try=0;			/**     * Error received by SMTP Protocol     * @public     * @type int     */	var $Recup_code_error = null;    /**     *  Sets the default SMTP server port. Default value is 25.     *  @public     *  @type int     */    var $Port        = 25;    /**     *  Sets the SMTP HELO of the message.     *  Default value is "localhost.localdomain".     *  @public     *  @type string     */    var $Helo        = "localhost.localdomain";     /**     *  Sets SMTP authentication. Utilizes the Username and Password variables.     *  Default value is false (off).     *  @public     *  @type bool     */    var $SMTPAuth     = false;    /**     *  Sets SMTP username. Default value is "".     *  @public     *  @type string     */    var $Username     = "";    /**     *  Sets SMTP password. Default value is "".     *  @public     *  @type string     */    var $Password     = "";    /**     *  Sets the SMTP server timeout in seconds. Does not function at this time     *  because PHP for win32 does not support it. Default value is 10.     *  @public     *  @type int     */    var $Timeout      = 10;    /**     *  Sets SMTP class debugging on or off. Default value is false (off).     *  @public     *  @type bool     */    var $SMTPDebug    = false;    /**     *  Sets ROLL ROUND debugging on or off. Default value is false (off).     *  @public     *  @type bool     */    var $Debug_Roll    = false;    /////////////////////////////////////////////////    // PRIVATE VARIABLES    /////////////////////////////////////////////////    /**     *  Holds all "To" addresses.     *  @type array     */    var $to              = array();    /**     *  Holds all "CC" addresses.     *  @type array     */    var $cc              = array();    /**     *  Holds all "BCC" addresses.     *  @type array     */    var $bcc             = array();    /**     *  Holds all "Reply-To" addresses.     *  @type array     */    var $ReplyTo         = array();    /**     *  Holds all string and binary attachments.     *  @type array     */    var $attachment      = array();    /**     *  Holds all custom headers.     *  @type array     */    var $CustomHeader    = array();    /**     *  Holds the message boundary. Default is false.     *  @type string     */    var $boundary        = false;    /**     *  Holds the message boundary. This is used specifically     *  when multipart/alternative messages are sent. Default is false.     *  @type string     */    var $subboundary     = false;    /////////////////////////////////////////////////    // CLASS CONSTRUCTOR : phpmailer    /////////////////////////////////////////////////	function phpmailer () {         		  		  		  if ($this->Debug_Roll) echo $this -> Host;	}    /////////////////////////////////////////////////    // VARIABLE METHODS    /////////////////////////////////////////////////    /**     * Sets message type to HTML.  Returns void.     * @public     * @returns 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.     * @public     * @returns void     */    function IsSMTP() {        $this->Mailer = "smtp";    }    /**     * Sets Mailer to send message using PHP mail() function.     * Returns void.     * @public     * @returns void     */    function IsMail() {        $this->Mailer = "mail";    }    /**     * Sets Mailer to send message using the $Sendmail program.     * Returns void.     * @public     * @returns void     */    function Issendmail() {        $this->Mailer = "sendmail";    }    /**     * Sets Mailer to send message using the qmail MTA.  Returns void.     * @public     * @returns 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.     * @public     * @returns 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.     * @public     * @returns 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.     * @public     * @returns 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.     * @public     * @returns 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.     * @public     * @returns bool     */    function Send() {        if(count($this->to) < 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";        $header = $this->create_header();        if(!$body = $this->create_body())            return false;        //echo "<pre>".$header . $body . "</pre>"; // debugging

⌨️ 快捷键说明

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