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

📄 class.phpmailer.php

📁 邮箱加即时聊天
💻 PHP
📖 第 1 页 / 共 4 页
字号:
    }    /* 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.   * @param string $string String attachment data.   * @param string $filename Name of the attachment.   * @param string $encoding File encoding (see $Encoding).   * @param string $type File extension (MIME) type.   * @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.  Make sure to set the $type to an   * image type.  For JPEG images use "image/jpeg" and for GIF images   * use "image/gif".   * @param string $path Path to the attachment.   * @param string $cid Content ID of the attachment.  Use this to identify   *        the Id for accessing the image in an HTML form.   * @param string $name Overrides the attachment name.   * @param string $encoding File encoding (see $Encoding).   * @param string $type File extension (MIME) type.   * @return bool   */  function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {    if(!@is_file($path)) {      $this->SetError($this->Lang('file_access') . $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;    $this->attachment[$cur][6] = 'inline';    $this->attachment[$cur][7] = $cid;    return true;  }  /**   * Returns true if an inline attachment is present.   * @access private   * @return bool   */  function InlineImageExists() {    $result = false;    for($i = 0; $i < count($this->attachment); $i++) {      if($this->attachment[$i][6] == 'inline') {        $result = true;        break;      }    }    return $result;  }  /////////////////////////////////////////////////  // CLASS METHODS, MESSAGE RESET  /////////////////////////////////////////////////  /**   * Clears all recipients assigned in the TO array.  Returns void.   * @return void   */  function ClearAddresses() {    $this->to = array();  }  /**   * Clears all recipients assigned in the CC array.  Returns void.   * @return void   */  function ClearCCs() {    $this->cc = array();  }  /**   * Clears all recipients assigned in the BCC array.  Returns void.   * @return void   */  function ClearBCCs() {    $this->bcc = array();  }  /**   * Clears all recipients assigned in the ReplyTo array.  Returns void.   * @return void   */  function ClearReplyTos() {    $this->ReplyTo = array();  }  /**   * Clears all recipients assigned in the TO, CC and BCC   * array.  Returns void.   * @return void   */  function ClearAllRecipients() {    $this->to = array();    $this->cc = array();    $this->bcc = array();  }  /**   * Clears all previously set filesystem, string, and binary   * attachments.  Returns void.   * @return void   */  function ClearAttachments() {    $this->attachment = array();  }  /**   * Clears all custom headers.  Returns void.   * @return void   */  function ClearCustomHeaders() {    $this->CustomHeader = array();  }  /////////////////////////////////////////////////  // CLASS METHODS, MISCELLANEOUS  /////////////////////////////////////////////////  /**   * Adds the error message to the error container.   * Returns void.   * @access private   * @return void   */  function SetError($msg) {    $this->error_count++;    $this->ErrorInfo = $msg;  }  /**   * Returns the proper RFC 822 formatted date.   * @access private   * @return string   */  function RFCDate() {    $tz = date('Z');    $tzs = ($tz < 0) ? '-' : '+';    $tz = abs($tz);    $tz = (int)($tz/3600)*100 + ($tz%3600)/60;    $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz);    return $result;  }  /**   * 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 ServerVar($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 ServerHostname() {    if ($this->Hostname != '') {      $result = $this->Hostname;    } elseif ($this->ServerVar('SERVER_NAME') != '') {      $result = $this->ServerVar('SERVER_NAME');    } else {      $result = 'localhost.localdomain';    }    return $result;  }  /**   * Returns a message in the appropriate language.   * @access private   * @return string   */  function Lang($key) {    if(count($this->language) < 1) {      $this->SetLanguage('en'); // set the default language    }    if(isset($this->language[$key])) {      return $this->language[$key];    } else {      return 'Language string failed to load: ' . $key;    }  }  /**   * Returns true if an error occurred.   * @return bool   */  function IsError() {    return ($this->error_count > 0);  }  /**   * Changes every end of line from CR or LF to CRLF.   * @access private   * @return string   */  function FixEOL($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.   * @return void   */  function AddCustomHeader($custom_header) {    $this->CustomHeader[] = explode(':', $custom_header, 2);  }  /**   * Evaluates the message and returns modifications for inline images and backgrounds   * @access public   * @return $message   */  function MsgHTML($message,$basedir='') {    preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images);    if(isset($images[2])) {      foreach($images[2] as $i => $url) {        // do not change urls for absolute images (thanks to corvuscorax)        if (!preg_match('/^[A-z][A-z]*:\/\//',$url)) {          $filename = basename($url);          $directory = dirname($url);          ($directory == '.')?$directory='':'';          $cid = 'cid:' . md5($filename);          $fileParts = split("\.", $filename);          $ext = $fileParts[1];          $mimeType = $this->_mime_types($ext);          if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; }          if ( strlen($directory) > 1 && substr($basedir,-1) != '/') { $directory .= '/'; }          $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64', $mimeType);          if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) {            $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message);          }        }      }    }    $this->IsHTML(true);    $this->Body = $message;    $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message)));    if ( !empty($textMsg) && empty($this->AltBody) ) {      $this->AltBody = $textMsg;    }    if ( empty($this->AltBody) ) {      $this->AltBody = 'To view this email message, open the email in with HTML compatibility!' . "\n\n";    }  }  /**   * Gets the mime type of the embedded or inline image   * @access private   * @return mime type of ext   */  function _mime_types($ext = '') {    $mimes = array(      'hqx'  =>  'application/mac-binhex40',      'cpt'   =>  'application/mac-compactpro',      'doc'   =>  'application/msword',      'bin'   =>  'application/macbinary',      'dms'   =>  'application/octet-stream',      'lha'   =>  'application/octet-stream',      'lzh'   =>  'application/octet-stream',      'exe'   =>  'application/octet-stream',      'class' =>  'application/octet-stream',      'psd'   =>  'application/octet-stream',      'so'    =>  'application/octet-stream',      'sea'   =>  'application/octet-stream',      'dll'   =>  'application/octet-stream',      'oda'   =>  'application/oda',      'pdf'   =>  'application/pdf',      'ai'    =>  'application/postscript',      'eps'   =>  'application/postscript',      'ps'    =>  'application/postscript',      'smi'   =>  'application/smil',      'smil'  =>  'application/smil',      'mif'   =>  'application/vnd.mif',      'xls'   =>  'application/vnd.ms-excel',      'ppt'   =>  'application/vnd.ms-powerpoint',      'wbxml' =>  'application/vnd.wap.wbxml',      'wmlc'  =>  'application/vnd.wap.wmlc',      'dcr'   =>  'application/x-director',      'dir'   =>  'application/x-director',      'dxr'   =>  'application/x-director',      'dvi'   =>  'application/x-dvi',      'gtar'  =>  'application/x-gtar',      'php'   =>  'application/x-httpd-php',      'php4'  =>  'application/x-httpd-php',      'php3'  =>  'application/x-httpd-php',      'phtml' =>  'application/x-httpd-php',      'phps'  =>  'application/x-httpd-php-source',      'js'    =>  'application/x-javascript',      'swf'   =>  'application/x-shockwave-flash',      'sit'   =>  'application/x-stuffit',      'tar'   =>  'application/x-tar',      'tgz'   =>  'application/x-tar',      'xhtml' =>  'application/xhtml+xml',      'xht'   =>  'application/xhtml+xml',      'zip'   =>  'application/zip',      'mid'   =>  'audio/midi',      'midi'  =>  'audio/midi',      'mpga'  =>  'audio/mpeg',      'mp2'   =>  'audio/mpeg',      'mp3'   =>  'audio/mpeg',      'aif'   =>  'audio/x-aiff',      'aiff'  =>  'audio/x-aiff',      'aifc'  =>  'audio/x-aiff',      'ram'   =>  'audio/x-pn-realaudio',      'rm'    =>  'audio/x-pn-realaudio',      'rpm'   =>  'audio/x-pn-realaudio-plugin',      'ra'    =>  'audio/x-realaudio',      'rv'    =>  'video/vnd.rn-realvideo',      'wav'   =>  'audio/x-wav',      'bmp'   =>  'image/bmp',      'gif'   =>  'image/gif',      'jpeg'  =>  'image/jpeg',      'jpg'   =>  'image/jpeg',      'jpe'   =>  'image/jpeg',      'png'   =>  'image/png',      'tiff'  =>  'image/tiff',      'tif'   =>  'image/tiff',      'css'   =>  'text/css',      'html'  =>  'text/html',      'htm'   =>  'text/html',      'shtml' =>  'text/html',      'txt'   =>  'text/plain',      'text'  =>  'text/plain',      'log'   =>  'text/plain',      'rtx'   =>  'text/richtext',      'rtf'   =>  'text/rtf',      'xml'   =>  'text/xml',      'xsl'   =>  'text/xml',      'mpeg'  =>  'video/mpeg',      'mpg'   =>  'video/mpeg',      'mpe'   =>  'video/mpeg',      'qt'    =>  'video/quicktime',      'mov'   =>  'video/quicktime',      'avi'   =>  'video/x-msvideo',      'movie' =>  'video/x-sgi-movie',      'doc'   =>  'application/msword',      'word'  =>  'application/msword',      'xl'    =>  'application/excel',      'eml'   =>  'message/rfc822'    );    return ( ! isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)];  }  /**   * Set (or reset) Class Objects (variables)   *   * Usage Example:   * $page->set('X-Priority', '3');   *   * @access public   * @param string $name Parameter Name   * @param mixed $value Parameter Value   * NOTE: will not work with arrays, there are no arrays to set/reset   */  function set ( $name, $value = '' ) {    if ( isset($this->$name) ) {      $this->$name = $value;    } else {      $this->SetError('Cannot set or reset variable ' . $name);      return false;    }  }  /**   * Read a file from a supplied filename and return it.   *   * @access public   * @param string $filename Parameter File Name   */  function getFile($filename) {    $return = '';    if ($fp = fopen($filename, 'rb')) {      while (!feof($fp)) {        $return .= fread($fp, 1024);      }      fclose($fp);      return $return;    } else {      return false;    }  }  /**   * Strips newlines to prevent header injection.   * @access private   * @param string $str String   * @return string   */  function SecureHeader($str) {    $str = trim($str);    $str = str_replace("\r", "", $str);    $str = str_replace("\n", "", $str);    return $str;  }  /**   * Set the private key file and password to sign the message.   *   * @access public   * @param string $key_filename Parameter File Name   * @param string $key_pass Password for private key   */  function Sign($key_filename, $key_pass) {    $this->sign_key_file = $key_filename;    $this->sign_key_pass = $key_pass;  }}?>

⌨️ 快捷键说明

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