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

📄 email.php

📁 每个RFC 3261信息头有一个相应的存取标识. 但是,许多信息头拥有同样的形式。 例如。To和From的信息头都是由显示名和一个URI组成。 To和From信息头用来管理与处理NameAddr实例的
💻 PHP
📖 第 1 页 / 共 2 页
字号:
      $obj->addSubpart($value['body'], $params);    }/** * Adds an attachment subpart to a mime_part object *//* HPDL PHP3 *///    function &add_attachment_part(&$obj, $value) {    function add_attachment_part(&$obj, $value) {      $params['content_type'] = $value['c_type'];      $params['encoding'] = $value['encoding'];      $params['disposition'] = 'attachment';      $params['dfilename'] = $value['name'];      $obj->addSubpart($value['body'], $params);    }/** * Builds the multipart message from the * list ($this->_parts). $params is an * array of parameters that shape the building * of the message. Currently supported are: * * $params['html_encoding'] - The type of encoding to use on html. Valid options are *                            "7bit", "quoted-printable" or "base64" (all without quotes). *                            7bit is EXPRESSLY NOT RECOMMENDED. Default is quoted-printable * $params['text_encoding'] - The type of encoding to use on plain text Valid options are *                            "7bit", "quoted-printable" or "base64" (all without quotes). *                            Default is 7bit * $params['text_wrap']     - The character count at which to wrap 7bit encoded data. *                            Default this is 998. * $params['html_charset']  - The character set to use for a html section. *                            Default is iso-8859-1 * $params['text_charset']  - The character set to use for a text section. *                          - Default is iso-8859-1 *//* HPDL PHP3 *///    function build_message($params = array()) {    function build_message($params = '') {      if ($params == '') $params = array();      if (count($params) > 0) {        reset($params);        while(list($key, $value) = each($params)) {          $this->build_params[$key] = $value;        }      }      if (tep_not_null($this->html_images)) {        reset($this->html_images);        while (list(,$value) = each($this->html_images)) {          $this->html = str_replace($value['name'], 'cid:' . $value['cid'], $this->html);        }      }      $null = NULL;      $attachments = ((tep_not_null($this->attachments)) ? true : false);      $html_images = ((tep_not_null($this->html_images)) ? true : false);      $html = ((tep_not_null($this->html)) ? true : false);      $text = ((tep_not_null($this->text)) ? true : false);      switch (true) {        case (($text == true) && ($attachments == false)):/* HPDL PHP3 *///          $message =& $this->add_text_part($null, $this->text);          $message = $this->add_text_part($null, $this->text);          break;        case (($text == false) && ($attachments == true) && ($html == false)):/* HPDL PHP3 *///          $message =& $this->add_mixed_part();          $message = $this->add_mixed_part();          for ($i=0; $i<count($this->attachments); $i++) {            $this->add_attachment_part($message, $this->attachments[$i]);          }          break;        case (($text == true) && ($attachments == true)):/* HPDL PHP3 *///          $message =& $this->add_mixed_part();          $message = $this->add_mixed_part();          $this->add_text_part($message, $this->text);          for ($i=0; $i<count($this->attachments); $i++) {            $this->add_attachment_part($message, $this->attachments[$i]);          }          break;        case (($html == true) && ($attachments == false) && ($html_images == false)):          if (tep_not_null($this->html_text)) {/* HPDL PHP3 *///            $message =& $this->add_alternative_part($null);            $message = $this->add_alternative_part($null);            $this->add_text_part($message, $this->html_text);            $this->add_html_part($message);          } else {/* HPDL PHP3 *///            $message =& $this->add_html_part($null);            $message = $this->add_html_part($null);          }          break;        case (($html == true) && ($attachments == false) && ($html_images == true)):          if (tep_not_null($this->html_text)) {/* HPDL PHP3 *///            $message =& $this->add_alternative_part($null);            $message = $this->add_alternative_part($null);            $this->add_text_part($message, $this->html_text);/* HPDL PHP3 *///            $related =& $this->add_related_part($message);            $related = $this->add_related_part($message);          } else {/* HPDL PHP3 *///            $message =& $this->add_related_part($null);//            $related =& $message;            $message = $this->add_related_part($null);            $related = $message;          }          $this->add_html_part($related);          for ($i=0; $i<count($this->html_images); $i++) {            $this->add_html_image_part($related, $this->html_images[$i]);          }          break;        case (($html == true) && ($attachments == true) && ($html_images == false)):/* HPDL PHP3 *///          $message =& $this->add_mixed_part();          $message = $this->add_mixed_part();          if (tep_not_null($this->html_text)) {/* HPDL PHP3 *///            $alt =& $this->add_alternative_part($message);            $alt = $this->add_alternative_part($message);            $this->add_text_part($alt, $this->html_text);            $this->add_html_part($alt);          } else {            $this->add_html_part($message);          }          for ($i=0; $i<count($this->attachments); $i++) {            $this->add_attachment_part($message, $this->attachments[$i]);          }          break;        case (($html == true) && ($attachments == true) && ($html_images == true)):/* HPDL PHP3 *///          $message =& $this->add_mixed_part();          $message = $this->add_mixed_part();          if (tep_not_null($this->html_text)) {/* HPDL PHP3 *///            $alt =& $this->add_alternative_part($message);            $alt = $this->add_alternative_part($message);            $this->add_text_part($alt, $this->html_text);/* HPDL PHP3 *///            $rel =& $this->add_related_part($alt);            $rel = $this->add_related_part($alt);          } else {/* HPDL PHP3 *///            $rel =& $this->add_related_part($message);            $rel = $this->add_related_part($message);          }          $this->add_html_part($rel);          for ($i=0; $i<count($this->html_images); $i++) {            $this->add_html_image_part($rel, $this->html_images[$i]);          }          for ($i=0; $i<count($this->attachments); $i++) {            $this->add_attachment_part($message, $this->attachments[$i]);          }          break;      }      if ( (isset($message)) && (is_object($message)) ) {        $output = $message->encode();        $this->output = $output['body'];        reset($output['headers']);        while (list($key, $value) = each($output['headers'])) {          $headers[] = $key . ': ' . $value;        }        $this->headers = array_merge($this->headers, $headers);        return true;      } else {        return false;      }    }/** * Sends the mail. */    function send($to_name, $to_addr, $from_name, $from_addr, $subject = '', $headers = '') {      $to = (($to_name != '') ? '"' . $to_name . '" <' . $to_addr . '>' : $to_addr);      $from = (($from_name != '') ? '"' . $from_name . '" <' . $from_addr . '>' : $from_addr);      if (is_string($headers)) {        $headers = explode($this->lf, trim($headers));      }      for ($i=0; $i<count($headers); $i++) {        if (is_array($headers[$i])) {          for ($j=0; $j<count($headers[$i]); $j++) {            if ($headers[$i][$j] != '') {              $xtra_headers[] = $headers[$i][$j];            }          }        }        if ($headers[$i] != '') {          $xtra_headers[] = $headers[$i];        }      }      if (!isset($xtra_headers)) {        $xtra_headers = array();      }      if (EMAIL_TRANSPORT == 'smtp') {        return mail($to_addr, $subject, $this->output, 'From: ' . $from . $this->lf . 'To: ' . $to . $this->lf . implode($this->lf, $this->headers) . $this->lf . implode($this->lf, $xtra_headers));      } else {        return mail($to, $subject, $this->output, 'From: '.$from.$this->lf.implode($this->lf, $this->headers).$this->lf.implode($this->lf, $xtra_headers));      }    }/** * Use this method to return the email * in message/rfc822 format. Useful for * adding an email to another email as * an attachment. there's a commented * out example in example.php. * * string get_rfc822(string To name, *       string To email, *       string From name, *       string From email, *       [string Subject, *        string Extra headers]) */    function get_rfc822($to_name, $to_addr, $from_name, $from_addr, $subject = '', $headers = '') {// Make up the date header as according to RFC822      $date = 'Date: ' . date('D, d M y H:i:s');      $to = (($to_name != '') ? 'To: "' . $to_name . '" <' . $to_addr . '>' : 'To: ' . $to_addr);      $from = (($from_name != '') ? 'From: "' . $from_name . '" <' . $from_addr . '>' : 'From: ' . $from_addr);      if (is_string($subject)) {        $subject = 'Subject: ' . $subject;      }      if (is_string($headers)) {        $headers = explode($this->lf, trim($headers));      }      for ($i=0; $i<count($headers); $i++) {        if (is_array($headers[$i])) {          for ($j=0; $j<count($headers[$i]); $j++) {            if ($headers[$i][$j] != '') {              $xtra_headers[] = $headers[$i][$j];            }          }        }        if ($headers[$i] != '') {          $xtra_headers[] = $headers[$i];        }      }      if (!isset($xtra_headers)) {        $xtra_headers = array();      }      $headers = array_merge($this->headers, $xtra_headers);      return $date . $this->lf . $from . $this->lf . $to . $this->lf . $subject . $this->lf . implode($this->lf, $headers) . $this->lf . $this->lf . $this->output;    }  }?>

⌨️ 快捷键说明

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