Mail
[ class tree: Mail ] [ index: Mail ] [ all elements ]

Source for file mime.php

Documentation is available at mime.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  3. // +-----------------------------------------------------------------------+
  4. // | Copyright (c) 2002-2003  Richard Heyes                                |
  5. // | Copyright (c) 2003-2005  The PHP Group                                |
  6. // | All rights reserved.                                                  |
  7. // |                                                                       |
  8. // | Redistribution and use in source and binary forms, with or without    |
  9. // | modification, are permitted provided that the following conditions    |
  10. // | are met:                                                              |
  11. // |                                                                       |
  12. // | o Redistributions of source code must retain the above copyright      |
  13. // |   notice, this list of conditions and the following disclaimer.       |
  14. // | o Redistributions in binary form must reproduce the above copyright   |
  15. // |   notice, this list of conditions and the following disclaimer in the |
  16. // |   documentation and/or other materials provided with the distribution.|
  17. // | o The names of the authors may not be used to endorse or promote      |
  18. // |   products derived from this software without specific prior written  |
  19. // |   permission.                                                         |
  20. // |                                                                       |
  21. // | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |
  22. // | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |
  23. // | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
  24. // | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |
  25. // | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
  26. // | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |
  27. // | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
  28. // | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
  29. // | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |
  30. // | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
  31. // | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |
  32. // |                                                                       |
  33. // +-----------------------------------------------------------------------+
  34. // | Author: Richard Heyes <richard@phpguru.org>                           |
  35. // |         Tomas V.V.Cox <cox@idecnet.com> (port to PEAR)                |
  36. // +-----------------------------------------------------------------------+
  37. //
  38. // $Id: mime.php,v 1.35 2005/03/26 22:07:56 cipri Exp $
  39.  
  40. require_once('PEAR.php');
  41. require_once('Mail/mimePart.php');
  42.  
  43. /**
  44.  * Mime mail composer class. Can handle: text and html bodies, embedded html
  45.  * images and attachments.
  46.  * Documentation and examples of this class are avaible here:
  47.  * http://pear.php.net/manual/
  48.  *
  49.  * @notes This class is based on HTML Mime Mail class from
  50.  *    Richard Heyes <richard@phpguru.org> which was based also
  51.  *    in the mime_mail.class by Tobias Ratschiller <tobias@dnet.it> and
  52.  *    Sascha Schumann <sascha@schumann.cx>
  53.  *
  54.  * @author   Richard Heyes <richard.heyes@heyes-computing.net>
  55.  * @author   Tomas V.V.Cox <cox@idecnet.com>
  56.  * @package  Mail
  57.  * @access   public
  58.  */
  59. class Mail_mime
  60. {
  61.     /**
  62.      * Contains the plain text part of the email
  63.      * @var string 
  64.      */
  65.     var $_txtbody;
  66.     /**
  67.      * Contains the html part of the email
  68.      * @var string 
  69.      */
  70.     var $_htmlbody;
  71.     /**
  72.      * contains the mime encoded text
  73.      * @var string 
  74.      */
  75.     var $_mime;
  76.     /**
  77.      * contains the multipart content
  78.      * @var string 
  79.      */
  80.     var $_multipart;
  81.     /**
  82.      * list of the attached images
  83.      * @var array 
  84.      */
  85.     var $_html_images = array();
  86.     /**
  87.      * list of the attachements
  88.      * @var array 
  89.      */
  90.     var $_parts = array();
  91.     /**
  92.      * Build parameters
  93.      * @var array 
  94.      */
  95.     var $_build_params = array();
  96.     /**
  97.      * Headers for the mail
  98.      * @var array 
  99.      */
  100.     var $_headers = array();
  101.     /**
  102.      * End Of Line sequence (for serialize)
  103.      * @var string 
  104.      */
  105.     var $_eol;
  106.  
  107.  
  108.     /**
  109.      * Constructor function
  110.      *
  111.      * @access public
  112.      */
  113.     function Mail_mime($crlf "\r\n")
  114.     {
  115.         $this->_setEOL($crlf);
  116.         $this->_build_params = array(
  117.                                      'text_encoding' => '7bit',
  118.                                      'html_encoding' => 'quoted-printable',
  119.                                      '7bit_wrap'     => 998,
  120.                                      'html_charset'  => 'ISO-8859-1',
  121.                                      'text_charset'  => 'ISO-8859-1',
  122.                                      'head_charset'  => 'ISO-8859-1'
  123.                                     );
  124.     }
  125.  
  126.     /**
  127.      * Wakeup (unserialize) - re-sets EOL constant
  128.      *
  129.      * @access private
  130.      */
  131.     function __wakeup()
  132.     {
  133.         $this->_setEOL($this->_eol);
  134.     }
  135.  
  136.     /**
  137.      * Accessor function to set the body text. Body text is used if
  138.      * it's not an html mail being sent or else is used to fill the
  139.      * text/plain part that emails clients who don't support
  140.      * html should show.
  141.      *
  142.      * @param  string  $data   Either a string or
  143.      *                          the file name with the contents
  144.      * @param  bool    $isfile If true the first param should be treated
  145.      *                          as a file name, else as a string (default)
  146.      * @param  bool    $append If true the text or file is appended to
  147.      *                          the existing body, else the old body is
  148.      *                          overwritten
  149.      * @return mixed   true on success or PEAR_Error object
  150.      * @access public
  151.      */
  152.     function setTXTBody($data$isfile = false$append = false)
  153.     {
  154.         if (!$isfile{
  155.             if (!$append{
  156.                 $this->_txtbody $data;
  157.             else {
  158.                 $this->_txtbody .= $data;
  159.             }
  160.         else {
  161.             $cont $this->_file2str($data);
  162.             if (PEAR::isError($cont)) {
  163.                 return $cont;
  164.             }
  165.             if (!$append{
  166.                 $this->_txtbody $cont;
  167.             else {
  168.                 $this->_txtbody .= $cont;
  169.             }
  170.         }
  171.         return true;
  172.     }
  173.  
  174.     /**
  175.      * Adds a html part to the mail
  176.      *
  177.      * @param  string  $data   Either a string or the file name with the
  178.      *                          contents
  179.      * @param  bool    $isfile If true the first param should be treated
  180.      *                          as a file name, else as a string (default)
  181.      * @return mixed   true on success or PEAR_Error object
  182.      * @access public
  183.      */
  184.     function setHTMLBody($data$isfile = false)
  185.     {
  186.         if (!$isfile{
  187.             $this->_htmlbody $data;
  188.         else {
  189.             $cont $this->_file2str($data);
  190.             if (PEAR::isError($cont)) {
  191.                 return $cont;
  192.             }
  193.             $this->_htmlbody $cont;
  194.         }
  195.  
  196.         return true;
  197.     }
  198.  
  199.     /**
  200.      * Adds an image to the list of embedded images.
  201.      *
  202.      * @param  string  $file       The image file name OR image data itself
  203.      * @param  string  $c_type     The content type
  204.      * @param  string  $name       The filename of the image.
  205.      *                              Only use if $file is the image data
  206.      * @param  bool    $isfilename Whether $file is a filename or not
  207.      *                              Defaults to true
  208.      * @return mixed   true on success or PEAR_Error object
  209.      * @access public
  210.      */
  211.     function addHTMLImage($file$c_type='application/octet-stream',
  212.                           $name ''$isfilename = true)
  213.     {
  214.         $filedata ($isfilename === true$this->_file2str($file)
  215.                                            : $file;
  216.         if ($isfilename === true{
  217.             $filename ($name == '' basename($filebasename($name));
  218.         else {
  219.             $filename basename($name);
  220.         }
  221.         if (PEAR::isError($filedata)) {
  222.             return $filedata;
  223.         }
  224.         $this->_html_images[= array(
  225.                                       'body'   => $filedata,
  226.                                       'name'   => $filename,
  227.                                       'c_type' => $c_type,
  228.                                       'cid'    => md5(uniqid(time()))
  229.                                      );
  230.         return true;
  231.     }
  232.  
  233.     /**
  234.      * Adds a file to the list of attachments.
  235.      *
  236.      * @param  string  $file       The file name of the file to attach
  237.      *                              OR the file data itself
  238.      * @param  string  $c_type     The content type
  239.      * @param  string  $name       The filename of the attachment
  240.      *                              Only use if $file is the file data
  241.      * @param  bool    $isFilename Whether $file is a filename or not
  242.      *                              Defaults to true
  243.      * @return mixed true on success or PEAR_Error object
  244.      * @access public
  245.      */
  246.     function addAttachment($file$c_type 'application/octet-stream',
  247.                            $name ''$isfilename = true,
  248.                            $encoding 'base64')
  249.     {
  250.         $filedata ($isfilename === true$this->_file2str($file)
  251.                                            : $file;
  252.         if ($isfilename === true{
  253.             // Force the name the user supplied, otherwise use $file
  254.             $filename (!empty($name)) $name $file;
  255.         else {
  256.             $filename $name;
  257.         }
  258.         if (empty($filename)) {
  259.             return PEAR::raiseError(
  260.               'The supplied filename for the attachment can\'t be empty'
  261.             );
  262.         }
  263.         $filename basename($filename);
  264.         if (PEAR::isError($filedata)) {
  265.             return $filedata;
  266.         }
  267.  
  268.         $this->_parts[= array(
  269.                                 'body'     => $filedata,
  270.                                 'name'     => $filename,
  271.                                 'c_type'   => $c_type,
  272.                                 'encoding' => $encoding
  273.                                );
  274.         return true;
  275.     }
  276.  
  277.     /**
  278.      * Get the contents of the given file name as string
  279.      *
  280.      * @param  string  $file_name  path of file to process
  281.      * @return string  contents of $file_name
  282.      * @access private
  283.      */
  284.     function &_file2str($file_name)
  285.     {
  286.         if (!is_readable($file_name)) {
  287.             return PEAR::raiseError('File is not readable ' $file_name);
  288.         }
  289.         if (!$fd fopen($file_name'rb')) {
  290.             return PEAR::raiseError('Could not open ' $file_name);
  291.         }
  292.         $cont fread($fdfilesize($file_name));
  293.         fclose($fd);
  294.         return $cont;
  295.     }
  296.  
  297.     /**
  298.      * Adds a text subpart to the mimePart object and
  299.      * returns it during the build process.
  300.      *
  301.      * @param mixed    The object to add the part to, or
  302.      *                  null if a new object is to be created.
  303.      * @param string   The text to add.
  304.      * @return object  The text mimePart object
  305.      * @access private
  306.      */
  307.     function &_addTextPart(&$obj$text)
  308.     {
  309.         $params['content_type''text/plain';
  310.         $params['encoding']     $this->_build_params['text_encoding'];
  311.         $params['charset']      $this->_build_params['text_charset'];
  312.         if (is_object($obj)) {
  313.             return $obj->addSubpart($text$params);
  314.         else {
  315.             return new Mail_mimePart($text$params);
  316.         }
  317.     }
  318.  
  319.     /**
  320.      * Adds a html subpart to the mimePart object and
  321.      * returns it during the build process.
  322.      *
  323.      * @param  mixed   The object to add the part to, or
  324.      *                  null if a new object is to be created.
  325.      * @return object  The html mimePart object
  326.      * @access private
  327.      */
  328.     function &_addHtmlPart(&$obj)
  329.     {
  330.         $params['content_type''text/html';
  331.         $params['encoding']     $this->_build_params['html_encoding'];
  332.         $params['charset']      $this->_build_params['html_charset'];
  333.         if (is_object($obj)) {
  334.             return $obj->addSubpart($this->_htmlbody$params);
  335.         else {
  336.             return new Mail_mimePart($this->_htmlbody$params);
  337.         }
  338.     }
  339.  
  340.     /**
  341.      * Creates a new mimePart object, using multipart/mixed as
  342.      * the initial content-type and returns it during the
  343.      * build process.
  344.      *
  345.      * @return object  The multipart/mixed mimePart object
  346.      * @access private
  347.      */
  348.     function &_addMixedPart()
  349.     {
  350.         $params['content_type''multipart/mixed';
  351.         return new Mail_mimePart(''$params);
  352.     }
  353.  
  354.     /**
  355.      * Adds a multipart/alternative part to a mimePart
  356.      * object (or creates one), and returns it during
  357.      * the build process.
  358.      *
  359.      * @param  mixed   The object to add the part to, or
  360.      *                  null if a new object is to be created.
  361.      * @return object  The multipart/mixed mimePart object
  362.      * @access private
  363.      */
  364.     function &_addAlternativePart(&$obj)
  365.     {
  366.         $params['content_type''multipart/alternative';
  367.         if (is_object($obj)) {
  368.             return $obj->addSubpart(''$params);
  369.         else {
  370.             return new Mail_mimePart(''$params);
  371.         }
  372.     }
  373.  
  374.     /**
  375.      * Adds a multipart/related part to a mimePart
  376.      * object (or creates one), and returns it during
  377.      * the build process.
  378.      *
  379.      * @param mixed    The object to add the part to, or
  380.      *                  null if a new object is to be created
  381.      * @return object  The multipart/mixed mimePart object
  382.      * @access private
  383.      */
  384.     function &_addRelatedPart(&$obj)
  385.     {
  386.         $params['content_type''multipart/related';
  387.         if (is_object($obj)) {
  388.             return $obj->addSubpart(''$params);
  389.         else {
  390.             return new Mail_mimePart(''$params);
  391.         }
  392.     }
  393.  
  394.     /**
  395.      * Adds an html image subpart to a mimePart object
  396.      * and returns it during the build process.
  397.      *
  398.      * @param  object  The mimePart to add the image to
  399.      * @param  array   The image information
  400.      * @return object  The image mimePart object
  401.      * @access private
  402.      */
  403.     function &_addHtmlImagePart(&$obj$value)
  404.     {
  405.         $params['content_type'$value['c_type'];
  406.         $params['encoding']     'base64';
  407.         $params['disposition']  'inline';
  408.         $params['dfilename']    $value['name'];
  409.         $params['cid']          $value['cid'];
  410.         $obj->addSubpart($value['body']$params);
  411.     }
  412.  
  413.     /**
  414.      * Adds an attachment subpart to a mimePart object
  415.      * and returns it during the build process.
  416.      *
  417.      * @param  object  The mimePart to add the image to
  418.      * @param  array   The attachment information
  419.      * @return object  The image mimePart object
  420.      * @access private
  421.      */
  422.     function &_addAttachmentPart(&$obj$value)
  423.     {
  424.         $params['content_type'$value['c_type'];
  425.         $params['encoding']     $value['encoding'];
  426.         $params['disposition']  'attachment';
  427.         $params['dfilename']    $value['name'];
  428.         $obj->addSubpart($value['body']$params);
  429.     }
  430.  
  431.     /**
  432.      * Builds the multipart message from the list ($this->_parts) and
  433.      * returns the mime content.
  434.      *
  435.      * @param  array  Build parameters that change the way the email
  436.      *                 is built. Should be associative. Can contain:
  437.      *                 text_encoding  -  What encoding to use for plain text
  438.      *                                   Default is 7bit
  439.      *                 html_encoding  -  What encoding to use for html
  440.      *                                   Default is quoted-printable
  441.      *                 7bit_wrap      -  Number of characters before text is
  442.      *                                   wrapped in 7bit encoding
  443.      *                                   Default is 998
  444.      *                 html_charset   -  The character set to use for html.
  445.      *                                   Default is iso-8859-1
  446.      *                 text_charset   -  The character set to use for text.
  447.      *                                   Default is iso-8859-1
  448.      *                 head_charset   -  The character set to use for headers.
  449.      *                                   Default is iso-8859-1
  450.      * @return string The mime content
  451.      * @access public
  452.      */
  453.     function &get($build_params = null)
  454.     {
  455.         if (isset($build_params)) {
  456.             while (list($key$valueeach($build_params)) {
  457.                 $this->_build_params[$key$value;
  458.             }
  459.         }
  460.  
  461.         if (!empty($this->_html_imagesAND isset($this->_htmlbody)) {
  462.             foreach ($this->_html_images as $value{
  463.                 $regex '#src\s*=\s*(["\']?)' preg_quote($value['name'].
  464.                          '(["\'])?#';
  465.                 $rep 'src=\1cid:' $value['cid'.'\2';
  466.                 $this->_htmlbody preg_replace($regex$rep,
  467.                                        $this->_htmlbody
  468.                                    );
  469.             }
  470.         }
  471.  
  472.         $null        = null;
  473.         $attachments !empty($this->_parts)                ? true : false;
  474.         $html_images !empty($this->_html_images)          ? true : false;
  475.         $html        !empty($this->_htmlbody)             ? true : false;
  476.         $text        (!$html AND !empty($this->_txtbody)) ? true : false;
  477.  
  478.         switch (true{
  479.         case $text AND !$attachments:
  480.             $message =$this->_addTextPart($null$this->_txtbody);
  481.             break;
  482.  
  483.         case !$text AND !$html AND $attachments:
  484.             $message =$this->_addMixedPart();
  485.             for ($i = 0; $i count($this->_parts)$i++{
  486.                 $this->_addAttachmentPart($message$this->_parts[$i]);
  487.             }
  488.             break;
  489.  
  490.         case $text AND $attachments:
  491.             $message =$this->_addMixedPart();
  492.             $this->_addTextPart($message$this->_txtbody);
  493.             for ($i = 0; $i count($this->_parts)$i++{
  494.                 $this->_addAttachmentPart($message$this->_parts[$i]);
  495.             }
  496.             break;
  497.  
  498.         case $html AND !$attachments AND !$html_images:
  499.             if (isset($this->_txtbody)) {
  500.                 $message =$this->_addAlternativePart($null);
  501.                 $this->_addTextPart($message$this->_txtbody);
  502.                 $this->_addHtmlPart($message);
  503.             else {
  504.                 $message =$this->_addHtmlPart($null);
  505.             }
  506.             break;
  507.  
  508.         case $html AND !$attachments AND $html_images:
  509.             if (isset($this->_txtbody)) {
  510.                 $message =$this->_addAlternativePart($null);
  511.                 $this->_addTextPart($message$this->_txtbody);
  512.                 $related =$this->_addRelatedPart($message);
  513.             else {
  514.                 $message =$this->_addRelatedPart($null);
  515.                 $related =$message;
  516.             }
  517.             $this->_addHtmlPart($related);
  518.             for ($i = 0; $i count($this->_html_images)$i++{
  519.                 $this->_addHtmlImagePart($related$this->_html_images[$i]);
  520.             }
  521.             break;
  522.  
  523.         case $html AND $attachments AND !$html_images:
  524.             $message =$this->_addMixedPart();
  525.             if (isset($this->_txtbody)) {
  526.                 $alt =$this->_addAlternativePart($message);
  527.                 $this->_addTextPart($alt$this->_txtbody);
  528.                 $this->_addHtmlPart($alt);
  529.             else {
  530.                 $this->_addHtmlPart($message);
  531.             }
  532.             for ($i = 0; $i count($this->_parts)$i++{
  533.                 $this->_addAttachmentPart($message$this->_parts[$i]);
  534.             }
  535.             break;
  536.  
  537.         case $html AND $attachments AND $html_images:
  538.             $message =$this->_addMixedPart();
  539.             if (isset($this->_txtbody)) {
  540.                 $alt =$this->_addAlternativePart($message);
  541.                 $this->_addTextPart($alt$this->_txtbody);
  542.                 $rel =$this->_addRelatedPart($alt);
  543.             else {
  544.                 $rel =$this->_addRelatedPart($message);
  545.             }
  546.             $this->_addHtmlPart($rel);
  547.             for ($i = 0; $i count($this->_html_images)$i++{
  548.                 $this->_addHtmlImagePart($rel$this->_html_images[$i]);
  549.             }
  550.             for ($i = 0; $i count($this->_parts)$i++{
  551.                 $this->_addAttachmentPart($message$this->_parts[$i]);
  552.             }
  553.             break;
  554.  
  555.         }
  556.  
  557.         if (isset($message)) {
  558.             $output $message->encode();
  559.             $this->_headers array_merge($this->_headers,
  560.                                           $output['headers']);
  561.             return $output['body'];
  562.  
  563.         else {
  564.             return false;
  565.         }
  566.     }
  567.  
  568.     /**
  569.      * Returns an array with the headers needed to prepend to the email
  570.      * (MIME-Version and Content-Type). Format of argument is:
  571.      * $array['header-name'] = 'header-value';
  572.      *
  573.      * @param  array $xtra_headers Assoc array with any extra headers.
  574.      *                              Optional.
  575.      * @return array Assoc array with the mime headers
  576.      * @access public
  577.      */
  578.     function &headers($xtra_headers = null)
  579.     {
  580.         // Content-Type header should already be present,
  581.         // So just add mime version header
  582.         $headers['MIME-Version''1.0';
  583.         if (isset($xtra_headers)) {
  584.             $headers array_merge($headers$xtra_headers);
  585.         }
  586.         $this->_headers array_merge($headers$this->_headers);
  587.  
  588.         return $this->_encodeHeaders($this->_headers);
  589.     }
  590.  
  591.     /**
  592.      * Get the text version of the headers
  593.      * (usefull if you want to use the PHP mail() function)
  594.      *
  595.      * @param  array   $xtra_headers Assoc array with any extra headers.
  596.      *                                Optional.
  597.      * @return string  Plain text headers
  598.      * @access public
  599.      */
  600.     function txtHeaders($xtra_headers = null)
  601.     {
  602.         $headers $this->headers($xtra_headers);
  603.         $ret '';
  604.         foreach ($headers as $key => $val{
  605.             $ret .= "$key$val" . MAIL_MIME_CRLF;
  606.         }
  607.         return $ret;
  608.     }
  609.  
  610.     /**
  611.      * Sets the Subject header
  612.      *
  613.      * @param  string $subject String to set the subject to
  614.      *  access  public
  615.      */
  616.     function setSubject($subject)
  617.     {
  618.         $this->_headers['Subject'$subject;
  619.     }
  620.  
  621.     /**
  622.      * Set an email to the From (the sender) header
  623.      *
  624.      * @param  string $email The email direction to add
  625.      * @access public
  626.      */
  627.     function setFrom($email)
  628.     {
  629.         $this->_headers['From'$email;
  630.     }
  631.  
  632.     /**
  633.      * Add an email to the Cc (carbon copy) header
  634.      * (multiple calls to this method are allowed)
  635.      *
  636.      * @param  string $email The email direction to add
  637.      * @access public
  638.      */
  639.     function addCc($email)
  640.     {
  641.         if (isset($this->_headers['Cc'])) {
  642.             $this->_headers['Cc'.= "$email";
  643.         else {
  644.             $this->_headers['Cc'$email;
  645.         }
  646.     }
  647.  
  648.     /**
  649.      * Add an email to the Bcc (blank carbon copy) header
  650.      * (multiple calls to this method are allowed)
  651.      *
  652.      * @param  string $email The email direction to add
  653.      * @access public
  654.      */
  655.     function addBcc($email)
  656.     {
  657.         if (isset($this->_headers['Bcc'])) {
  658.             $this->_headers['Bcc'.= "$email";
  659.         else {
  660.             $this->_headers['Bcc'$email;
  661.         }
  662.     }
  663.  
  664.     /**
  665.      * Encodes a header as per RFC2047
  666.      *
  667.      * @param  string  $input The header data to encode
  668.      * @return string  Encoded data
  669.      * @access private
  670.      */
  671.     function _encodeHeaders($input)
  672.     {
  673.         foreach ($input as $hdr_name => $hdr_value{
  674.             preg_match_all('/(\w*[\x80-\xFF]+\w*)/'$hdr_value$matches);
  675.             foreach ($matches[1as $value{
  676.                 $replacement preg_replace('/([\x80-\xFF])/e',
  677.                                             '"=" .
  678.                                             strtoupper(dechex(ord("\1")))',
  679.                                             $value);
  680.                 $hdr_value str_replace($value'=?' .
  681.                                          $this->_build_params['head_charset'.
  682.                                          '?Q?' $replacement '?=',
  683.                                          $hdr_value);
  684.             }
  685.             $input[$hdr_name$hdr_value;
  686.         }
  687.  
  688.         return $input;
  689.     }
  690.  
  691.     /**
  692.      * Set the object's end-of-line and define the constant if applicable
  693.      *
  694.      * @param string $eol End Of Line sequence
  695.      * @access private
  696.      */
  697.     function _setEOL($eol)
  698.     {
  699.         $this->_eol $eol;
  700.         if (!defined('MAIL_MIME_CRLF')) {
  701.             define('MAIL_MIME_CRLF'$this->_eoltrue);
  702.         }
  703.     }
  704.  
  705.     
  706.  
  707. // End of class
  708. ?>

Documentation generated on Mon, 11 Mar 2019 14:31:07 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.