Changeset ab6f807 in github


Ignore:
Timestamp:
Mar 21, 2007 5:54:10 AM (6 years ago)
Author:
thomascube <thomas@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
3cf6649
Parents:
ab71a53
Message:

Updated PEAR::Mail_mime package

Location:
program
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • program/lib/Mail/mime.php

    r5a6ad20 rab6f807  
    11<?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$ 
    39  
     2/** 
     3 * The Mail_Mime class is used to create MIME E-mail messages 
     4 * 
     5 * The Mail_Mime class provides an OO interface to create MIME 
     6 * enabled email messages. This way you can create emails that 
     7 * contain plain-text bodies, HTML bodies, attachments, inline 
     8 * images and specific headers. 
     9 * 
     10 * Compatible with PHP versions 4 and 5 
     11 * 
     12 * LICENSE: This LICENSE is in the BSD license style. 
     13 * Copyright (c) 2002-2003, Richard Heyes <richard@phpguru.org> 
     14 * Copyright (c) 2003-2006, PEAR <pear-group@php.net> 
     15 * All rights reserved. 
     16 * 
     17 * Redistribution and use in source and binary forms, with or 
     18 * without modification, are permitted provided that the following 
     19 * conditions are met: 
     20 * 
     21 * - Redistributions of source code must retain the above copyright 
     22 *   notice, this list of conditions and the following disclaimer. 
     23 * - Redistributions in binary form must reproduce the above copyright 
     24 *   notice, this list of conditions and the following disclaimer in the 
     25 *   documentation and/or other materials provided with the distribution. 
     26 * - Neither the name of the authors, nor the names of its contributors  
     27 *   may be used to endorse or promote products derived from this  
     28 *   software without specific prior written permission. 
     29 * 
     30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
     31 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
     33 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
     34 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
     35 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
     36 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
     37 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
     38 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
     39 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
     40 * THE POSSIBILITY OF SUCH DAMAGE. 
     41 * 
     42 * @category   Mail 
     43 * @package    Mail_Mime 
     44 * @author     Richard Heyes  <richard@phpguru.org> 
     45 * @author     Tomas V.V. Cox <cox@idecnet.com> 
     46 * @author     Cipriano Groenendal <cipri@php.net> 
     47 * @author     Sean Coates <sean@php.net> 
     48 * @copyright  2003-2006 PEAR <pear-group@php.net> 
     49 * @license    http://www.opensource.org/licenses/bsd-license.php BSD License 
     50 * @version    CVS: $Id$ 
     51 * @link       http://pear.php.net/package/Mail_mime 
     52 * @notes      This class is based on HTML Mime Mail class from 
     53 *             Richard Heyes <richard@phpguru.org> which was based also 
     54 *             in the mime_mail.class by Tobias Ratschiller <tobias@dnet.it> 
     55 *             and Sascha Schumann <sascha@schumann.cx> 
     56 */ 
     57 
     58 
     59/** 
     60 * require PEAR 
     61 * 
     62 * This package depends on PEAR to raise errors. 
     63 */ 
    4064require_once('PEAR.php'); 
     65 
     66/** 
     67 * require Mail_mimePart 
     68 * 
     69 * Mail_mimePart contains the code required to 
     70 * create all the different parts a mail can 
     71 * consist of. 
     72 */ 
    4173require_once('Mail/mimePart.php'); 
    4274 
     75 
    4376/** 
    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/ 
     77 * The Mail_Mime class provides an OO interface to create MIME 
     78 * enabled email messages. This way you can create emails that 
     79 * contain plain-text bodies, HTML bodies, attachments, inline 
     80 * images and specific headers. 
    4881 * 
    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 
     82 * @category   Mail 
     83 * @package    Mail_Mime 
     84 * @author     Richard Heyes  <richard@phpguru.org> 
     85 * @author     Tomas V.V. Cox <cox@idecnet.com> 
     86 * @author     Cipriano Groenendal <cipri@php.net> 
     87 * @author     Sean Coates <sean@php.net> 
     88 * @copyright  2003-2006 PEAR <pear-group@php.net> 
     89 * @license    http://www.opensource.org/licenses/bsd-license.php BSD License 
     90 * @version    Release: @package_version@ 
     91 * @link       http://pear.php.net/package/Mail_mime 
    5892 */ 
    5993class Mail_mime 
     
    6195    /** 
    6296     * Contains the plain text part of the email 
     97     * 
    6398     * @var string 
     99     * @access private 
    64100     */ 
    65101    var $_txtbody; 
     102 
    66103    /** 
    67104     * Contains the html part of the email 
     105     * 
    68106     * @var string 
     107     * @access private 
    69108     */ 
    70109    var $_htmlbody; 
     110 
    71111    /** 
    72112     * contains the mime encoded text 
     113     * 
    73114     * @var string 
     115     * @access private 
    74116     */ 
    75117    var $_mime; 
     118 
    76119    /** 
    77120     * contains the multipart content 
     121     * 
    78122     * @var string 
     123     * @access private 
    79124     */ 
    80125    var $_multipart; 
     126 
    81127    /** 
    82128     * list of the attached images 
     129     * 
    83130     * @var array 
     131     * @access private 
    84132     */ 
    85133    var $_html_images = array(); 
     134 
    86135    /** 
    87136     * list of the attachements 
     137     * 
    88138     * @var array 
     139     * @access private 
    89140     */ 
    90141    var $_parts = array(); 
     142 
    91143    /** 
    92144     * Build parameters 
     145     * 
    93146     * @var array 
     147     * @access private 
    94148     */ 
    95149    var $_build_params = array(); 
     150 
    96151    /** 
    97152     * Headers for the mail 
     153     * 
    98154     * @var array 
     155     * @access private 
    99156     */ 
    100157    var $_headers = array(); 
     158 
    101159    /** 
    102160     * End Of Line sequence (for serialize) 
     161     * 
    103162     * @var string 
     163     * @access private 
    104164     */ 
    105165    var $_eol; 
     
    107167 
    108168    /** 
    109      * Constructor function 
     169     * Constructor function. 
     170     * 
     171     * @param string $crlf  what type of linebreak to use. 
     172     *                       Defaults to "\r\n" 
     173     * @return void 
    110174     * 
    111175     * @access public 
     
    126190 
    127191    /** 
    128      * Wakeup (unserialize) - re-sets EOL constant 
     192     * wakeup function called by unserialize. It re-sets the EOL constant 
    129193     * 
    130194     * @access private 
     
    134198        $this->_setEOL($this->_eol); 
    135199    } 
     200 
    136201 
    137202    /** 
     
    142207     * 
    143208     * @param  string  $data   Either a string or 
    144      *                         the file name with the contents 
     209     *                          the file name with the contents 
    145210     * @param  bool    $isfile If true the first param should be treated 
    146      *                         as a file name, else as a string (default) 
     211     *                          as a file name, else as a string (default) 
    147212     * @param  bool    $append If true the text or file is appended to 
    148      *                         the existing body, else the old body is 
    149      *                         overwritten 
     213     *                          the existing body, else the old body is 
     214     *                          overwritten 
    150215     * @return mixed   true on success or PEAR_Error object 
    151216     * @access public 
     
    174239 
    175240    /** 
    176      * Adds a html part to the mail 
    177      * 
    178      * @param  string  $data   Either a string or the file name with the 
    179      *                         contents 
    180      * @param  bool    $isfile If true the first param should be treated 
    181      *                         as a file name, else as a string (default) 
    182      * @return mixed   true on success or PEAR_Error object 
     241     * Adds a html part to the mail. 
     242     * 
     243     * @param  string  $data   either a string or the file name with the 
     244     *                          contents 
     245     * @param  bool    $isfile a flag that determines whether $data is a 
     246     *                          filename, or a string(false, default) 
     247     * @return bool    true on success 
    183248     * @access public 
    184249     */ 
     
    199264 
    200265    /** 
    201     * returns the HTML body portion of the message 
    202     * @return string HTML body of the message 
    203     * @access public 
    204     */ 
    205     function getHTMLBody() 
    206     { 
    207        return $this->_htmlbody; 
    208     } 
    209      
    210     /** 
    211266     * Adds an image to the list of embedded images. 
    212267     * 
    213      * @param  string  $file       The image file name OR image data itself 
    214      * @param  string  $c_type     The content type 
    215      * @param  string  $name       The filename of the image. 
    216      *                             Only use if $file is the image data 
    217      * @param  bool    $isfilename Whether $file is a filename or not 
    218      *                             Defaults to true 
    219      * @param  string  $contentid  Desired Content-ID of MIME part 
    220      *                             Defaults to generated unique ID 
    221      * @return mixed   true on success or PEAR_Error object 
     268     * @param  string  $file       the image file name OR image data itself 
     269     * @param  string  $c_type     the content type 
     270     * @param  string  $name       the filename of the image. 
     271     *                              Only use if $file is the image data. 
     272     * @param  bool    $isfile     whether $file is a filename or not. 
     273     *                              Defaults to true 
     274     * @return bool                true on success 
    222275     * @access public 
    223276     */ 
    224277    function addHTMLImage($file, $c_type='application/octet-stream', 
    225                           $name = '', $isfilename = true, $contentid = '') 
    226     { 
    227         $filedata = ($isfilename === true) ? $this->_file2str($file) 
     278                          $name = '', $isfile = true) 
     279    { 
     280        $filedata = ($isfile === true) ? $this->_file2str($file) 
    228281                                           : $file; 
    229         if ($isfilename === true) { 
     282        if ($isfile === true) { 
    230283            $filename = ($name == '' ? $file : $name); 
    231284        } else { 
     
    234287        if (PEAR::isError($filedata)) { 
    235288            return $filedata; 
    236         } 
    237         if ($contentid == '') { 
    238            $contentid = md5(uniqid(time())); 
    239289        } 
    240290        $this->_html_images[] = array( 
     
    242292                                      'name'   => $filename, 
    243293                                      'c_type' => $c_type, 
    244                                       'cid'    => $contentid 
     294                                      'cid'    => md5(uniqid(time())) 
    245295                                     ); 
    246296        return true; 
     
    255305     * @param  string  $name        The filename of the attachment 
    256306     *                              Only use if $file is the contents 
    257      * @param  bool    $isFilename  Whether $file is a filename or not 
     307     * @param  bool    $isfile      Whether $file is a filename or not 
    258308     *                              Defaults to true 
    259309     * @param  string  $encoding    The type of encoding to use. 
     
    270320     */ 
    271321    function addAttachment($file, $c_type = 'application/octet-stream', 
    272                            $name = '', $isfilename = true, 
     322                           $name = '', $isfile = true, 
    273323                           $encoding = 'base64', 
    274324                           $disposition = 'attachment', $charset = '') 
    275325    { 
    276         $filedata = ($isfilename === true) ? $this->_file2str($file) 
     326        $filedata = ($isfile === true) ? $this->_file2str($file) 
    277327                                           : $file; 
    278         if ($isfilename === true) { 
     328        if ($isfile === true) { 
    279329            // Force the name the user supplied, otherwise use $file 
    280330            $filename = (!empty($name)) ? $name : $file; 
     
    478528        if ($value['disposition'] != "inline") { 
    479529            $fname = array("fname" => $value['name']); 
    480             $fname_enc = $this->_encodeHeaders($fname); 
     530            $fname_enc = $this->_encodeHeaders($fname, array('head_charset' => $value['charset'] ? $value['charset'] : 'iso-8859-1')); 
    481531            $params['dfilename'] = $fname_enc['fname']; 
    482532        } 
     
    797847     * Encodes a header as per RFC2047 
    798848     * 
    799      * @param  array $input The header data to encode 
     849     * @param  array $input  The header data to encode 
     850     * @param  array $params Extra build parameters 
    800851     * @return array Encoded data 
    801852     * @access private 
    802853     */ 
    803     function _encodeHeaders($input) 
    804     { 
    805         $maxlen = 73; 
     854    function _encodeHeaders($input, $params = array()) 
     855    { 
     856         
     857        $build_params = $this->_build_params; 
     858        while (list($key, $value) = each($params)) { 
     859            $build_params[$key] = $value; 
     860        } 
     861         
    806862        foreach ($input as $hdr_name => $hdr_value) { 
    807             // if header contains e-mail addresses 
    808             if (preg_match('/\s<.+@[a-z0-9\-\.]+\.[a-z]+>/U', $hdr_value)) 
    809                 $chunks = $this->_explode_quoted_string(',', $hdr_value); 
    810             else 
    811                $chunks = array($hdr_value); 
    812  
    813             $hdr_value = ''; 
    814             $line_len = 0; 
    815  
    816             foreach ($chunks as $i => $value) { 
    817                 $value = trim($value); 
    818  
    819                 //This header contains non ASCII chars and should be encoded. 
    820                 if (preg_match('#[\x80-\xFF]{1}#', $value)) { 
    821                     $suffix = ''; 
    822                     // Don't encode e-mail address 
    823                     if (preg_match('/(.+)\s(<.+@[a-z0-9\-\.]+>)$/Ui', $value, $matches)) { 
    824                         $value = $matches[1]; 
    825                         $suffix = ' '.$matches[2]; 
     863            $hdr_vals = preg_split("|(\s)|", $hdr_value, -1, PREG_SPLIT_DELIM_CAPTURE); 
     864            $hdr_value_out=""; 
     865            $previous = ""; 
     866            foreach ($hdr_vals as $hdr_val){ 
     867                if (!trim($hdr_val)){ 
     868                    //whitespace needs to be handled with another string, or it 
     869                    //won't show between encoded strings. Prepend this to the next item. 
     870                    $previous .= $hdr_val; 
     871                    continue; 
     872                }else{ 
     873                    $hdr_val = $previous . $hdr_val; 
     874                    $previous = ""; 
     875                } 
     876                if (function_exists('iconv_mime_encode') && preg_match('#[\x80-\xFF]{1}#', $hdr_val)){ 
     877                    $imePref = array(); 
     878                    if ($build_params['head_encoding'] == 'base64'){ 
     879                        $imePrefs['scheme'] = 'B'; 
     880                    }else{ 
     881                        $imePrefs['scheme'] = 'Q'; 
    826882                    } 
    827  
    828                     switch ($this->_build_params['head_encoding']) { 
     883                    $imePrefs['input-charset']  = $build_params['head_charset']; 
     884                    $imePrefs['output-charset'] = $build_params['head_charset']; 
     885                    $hdr_val = iconv_mime_encode($hdr_name, $hdr_val, $imePrefs); 
     886                    $hdr_val = preg_replace("#^{$hdr_name}\:\ #", "", $hdr_val); 
     887                }elseif (preg_match('#[\x80-\xFF]{1}#', $hdr_val)){ 
     888                    //This header contains non ASCII chars and should be encoded. 
     889                    switch ($build_params['head_encoding']) { 
    829890                    case 'base64': 
    830                         // Base64 encoding has been selected. 
    831                         $mode = 'B'; 
    832                         $encoded = base64_encode($value); 
     891                        //Base64 encoding has been selected. 
     892                         
     893                        //Generate the header using the specified params and dynamicly  
     894                        //determine the maximum length of such strings. 
     895                        //75 is the value specified in the RFC. The first -2 is there so  
     896                        //the later regexp doesn't break any of the translated chars. 
     897                        //The -2 on the first line-regexp is to compensate for the ": " 
     898                        //between the header-name and the header value 
     899                        $prefix = '=?' . $build_params['head_charset'] . '?B?'; 
     900                        $suffix = '?='; 
     901                        $maxLength = 75 - strlen($prefix . $suffix) - 2; 
     902                        $maxLength1stLine = $maxLength - strlen($hdr_name) - 2; 
     903                         
     904                        //Base64 encode the entire string 
     905                        $hdr_val = base64_encode($hdr_val); 
     906                         
     907                        //This regexp will break base64-encoded text at every  
     908                        //$maxLength but will not break any encoded letters. 
     909                        $reg1st = "|.{0,$maxLength1stLine}[^\=][^\=]|"; 
     910                        $reg2nd = "|.{0,$maxLength}[^\=][^\=]|"; 
    833911                        break; 
    834  
    835912                    case 'quoted-printable': 
    836913                    default: 
    837                         // quoted-printable encoding has been selected 
    838                         $mode = 'Q'; 
    839                         $encoded = preg_replace('/([\x2C\x3F\x80-\xFF])/e', "'='.sprintf('%02X', ord('\\1'))", $value); 
    840                         // replace spaces with _ 
    841                         $encoded = str_replace(' ', '_', $encoded); 
     914                        //quoted-printable encoding has been selected 
     915                         
     916                        //Generate the header using the specified params and dynamicly  
     917                        //determine the maximum length of such strings. 
     918                        //75 is the value specified in the RFC. The -2 is there so  
     919                        //the later regexp doesn't break any of the translated chars. 
     920                        //The -2 on the first line-regexp is to compensate for the ": " 
     921                        //between the header-name and the header value 
     922                        $prefix = '=?' . $build_params['head_charset'] . '?Q?'; 
     923                        $suffix = '?='; 
     924                        $maxLength = 75 - strlen($prefix . $suffix) - 2; 
     925                        $maxLength1stLine = $maxLength - strlen($hdr_name) - 2; 
     926                         
     927                        //Replace all special characters used by the encoder. 
     928                        $search  = array("=",   "_",   "?",   " "); 
     929                        $replace = array("=3D", "=5F", "=3F", "_"); 
     930                        $hdr_val = str_replace($search, $replace, $hdr_val); 
     931                         
     932                        //Replace all extended characters (\x80-xFF) with their 
     933                        //ASCII values. 
     934                        $hdr_val = preg_replace( 
     935                            '#([\x80-\xFF])#e', 
     936                            '"=" . strtoupper(dechex(ord("\1")))', 
     937                            $hdr_val 
     938                        ); 
     939                        //This regexp will break QP-encoded text at every $maxLength 
     940                        //but will not break any encoded letters. 
     941                        $reg1st = "|(.{0,$maxLength1stLine})[^\=]|"; 
     942                        $reg2nd = "|(.{0,$maxLength})[^\=]|"; 
     943                        break; 
    842944                    } 
    843  
    844                 $value = '=?' . $this->_build_params['head_charset'] . '?' . $mode . '?' . $encoded . '?=' . $suffix; 
     945                    //Begin with the regexp for the first line. 
     946                    $reg = $reg1st; 
     947                    //Prevent lins that are just way to short; 
     948                    if ($maxLength1stLine >1){ 
     949                        $reg = $reg2nd; 
     950                    } 
     951                    $output = ""; 
     952                    while ($hdr_val) { 
     953                        //Split translated string at every $maxLength 
     954                        //But make sure not to break any translated chars. 
     955                        $found = preg_match($reg, $hdr_val, $matches); 
     956                         
     957                        //After this first line, we need to use a different 
     958                        //regexp for the first line. 
     959                        $reg = $reg2nd; 
     960                         
     961                        //Save the found part and encapsulate it in the 
     962                        //prefix & suffix. Then remove the part from the 
     963                        //$hdr_val variable. 
     964                        if ($found){ 
     965                            $part = $matches[0]; 
     966                            $hdr_val = substr($hdr_val, strlen($matches[0])); 
     967                        }else{ 
     968                            $part = $hdr_val; 
     969                            $hdr_val = ""; 
     970                        } 
     971                         
     972                        //RFC 2047 specifies that any split header should be seperated 
     973                        //by a CRLF SPACE.  
     974                        if ($output){ 
     975                            $output .=  "\r\n "; 
     976                        } 
     977                        $output .= $prefix . $part . $suffix; 
     978                    } 
     979                    $hdr_val = $output; 
    845980                } 
    846  
    847                 // add chunk to output string by regarding the header maxlen 
    848                 $len = strlen($value); 
    849                 if ($line_len + $len < $maxlen) { 
    850                     $hdr_value .= ($i>0?', ':'') . $value; 
    851                     $line_len += $len + ($i>0?2:0); 
    852                 } 
    853                 else { 
    854                     $hdr_value .= ($i>0?', ':'') . "\n " . $value; 
    855                     $line_len = $len; 
    856                 } 
    857             } 
    858  
    859             $input[$hdr_name] = $hdr_value; 
     981                $hdr_value_out .= $hdr_val; 
     982            } 
     983            $input[$hdr_name] = $hdr_value_out; 
    860984        } 
    861985 
    862986        return $input; 
    863987    } 
    864  
    865  
    866   function _explode_quoted_string($delimiter, $string) 
    867     { 
    868     $quotes = explode("\"", $string); 
    869     foreach ($quotes as $key => $val) 
    870       if (($key % 2) == 1) 
    871         $quotes[$key] = str_replace($delimiter, "_!@!_", $quotes[$key]); 
    872  
    873     $string = implode("\"", $quotes); 
    874  
    875     $result = explode($delimiter, $string); 
    876     foreach ($result as $key => $val)  
    877       $result[$key] = str_replace("_!@!_", $delimiter, $result[$key]); 
    878  
    879     return $result; 
    880     } 
    881  
    882988 
    883989    /** 
     
    8981004 
    8991005} // End of class 
    900 ?> 
    901  
  • program/lib/Mail/mimeDecode.php

    r856110d rab6f807  
    11<?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 // +-----------------------------------------------------------------------+ 
    36  
     2/** 
     3 * The Mail_mimeDecode class is used to decode mail/mime messages 
     4 * 
     5 * This class will parse a raw mime email and return 
     6 * the structure. Returned structure is similar to 
     7 * that returned by imap_fetchstructure(). 
     8 * 
     9 *  +----------------------------- IMPORTANT ------------------------------+ 
     10 *  | Usage of this class compared to native php extensions such as        | 
     11 *  | mailparse or imap, is slow and may be feature deficient. If available| 
     12 *  | you are STRONGLY recommended to use the php extensions.              | 
     13 *  +----------------------------------------------------------------------+ 
     14 * 
     15 * Compatible with PHP versions 4 and 5 
     16 * 
     17 * LICENSE: This LICENSE is in the BSD license style. 
     18 * Copyright (c) 2002-2003, Richard Heyes <richard@phpguru.org> 
     19 * Copyright (c) 2003-2006, PEAR <pear-group@php.net> 
     20 * All rights reserved. 
     21 * 
     22 * Redistribution and use in source and binary forms, with or 
     23 * without modification, are permitted provided that the following 
     24 * conditions are met: 
     25 * 
     26 * - Redistributions of source code must retain the above copyright 
     27 *   notice, this list of conditions and the following disclaimer. 
     28 * - Redistributions in binary form must reproduce the above copyright 
     29 *   notice, this list of conditions and the following disclaimer in the 
     30 *   documentation and/or other materials provided with the distribution. 
     31 * - Neither the name of the authors, nor the names of its contributors  
     32 *   may be used to endorse or promote products derived from this  
     33 *   software without specific prior written permission. 
     34 * 
     35 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
     36 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
     38 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
     39 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
     40 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
     41 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
     42 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
     43 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
     44 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
     45 * THE POSSIBILITY OF SUCH DAMAGE. 
     46 * 
     47 * @category   Mail 
     48 * @package    Mail_Mime 
     49 * @author     Richard Heyes  <richard@phpguru.org> 
     50 * @author     George Schlossnagle <george@omniti.com> 
     51 * @author     Cipriano Groenendal <cipri@php.net> 
     52 * @author     Sean Coates <sean@php.net> 
     53 * @copyright  2003-2006 PEAR <pear-group@php.net> 
     54 * @license    http://www.opensource.org/licenses/bsd-license.php BSD License 
     55 * @version    CVS: $Id$ 
     56 * @link       http://pear.php.net/package/Mail_mime 
     57 */ 
     58 
     59 
     60/** 
     61 * require PEAR 
     62 * 
     63 * This package depends on PEAR to raise errors. 
     64 */ 
    3765require_once 'PEAR.php'; 
    3866 
     67 
    3968/** 
    40 *  +----------------------------- IMPORTANT ------------------------------+ 
    41 *  | Usage of this class compared to native php extensions such as        | 
    42 *  | mailparse or imap, is slow and may be feature deficient. If available| 
    43 *  | you are STRONGLY recommended to use the php extensions.              | 
    44 *  +----------------------------------------------------------------------+ 
    45 * 
    46 * Mime Decoding class 
    47 * 
    48 * This class will parse a raw mime email and return 
    49 * the structure. Returned structure is similar to 
    50 * that returned by imap_fetchstructure(). 
    51 * 
    52 * USAGE: (assume $input is your raw email) 
    53 * 
    54 * $decode = new Mail_mimeDecode($input, "\r\n"); 
    55 * $structure = $decode->decode(); 
    56 * print_r($structure); 
    57 * 
    58 * Or statically: 
    59 * 
    60 * $params['input'] = $input; 
    61 * $structure = Mail_mimeDecode::decode($params); 
    62 * print_r($structure); 
    63 * 
    64 * TODO: 
    65 *  o UTF8: ??? 
    66  
    67                 > 4. We have also found a solution for decoding the UTF-8  
    68                 > headers. Therefore I made the following function: 
    69                 >  
    70                 > function decode_utf8($txt) { 
    71                 > $trans=array("Å&#8216;"=>"õ","ű"=>"û","Ő"=>"Ã&#8226;","Ű" 
    72                 =>"Ã&#8250;"); 
    73                 > $txt=strtr($txt,$trans); 
    74                 > return(utf8_decode($txt)); 
    75                 > } 
    76                 >  
    77                 > And I have inserted the following line to the class: 
    78                 >  
    79                 > if (strtolower($charset)=="utf-8") $text=decode_utf8($text); 
    80                 >  
    81                 > ... before the following one in the "_decodeHeader" function: 
    82                 >  
    83                 > $input = str_replace($encoded, $text, $input); 
    84                 >  
    85                 > This way from now on it can easily decode the UTF-8 headers too. 
    86  
    87 * 
    88 * @author  Richard Heyes <richard@phpguru.org> 
    89 * @version $Revision$ 
    90 * @package Mail 
    91 */ 
     69 * The Mail_mimeDecode class is used to decode mail/mime messages 
     70 * 
     71 * This class will parse a raw mime email and return the structure. 
     72 * Returned structure is similar to that returned by imap_fetchstructure(). 
     73 * 
     74 *  +----------------------------- IMPORTANT ------------------------------+ 
     75 *  | Usage of this class compared to native php extensions such as        | 
     76 *  | mailparse or imap, is slow and may be feature deficient. If available| 
     77 *  | you are STRONGLY recommended to use the php extensions.              | 
     78 *  +----------------------------------------------------------------------+ 
     79 * 
     80 * @category   Mail 
     81 * @package    Mail_Mime 
     82 * @author     Richard Heyes  <richard@phpguru.org> 
     83 * @author     George Schlossnagle <george@omniti.com> 
     84 * @author     Cipriano Groenendal <cipri@php.net> 
     85 * @author     Sean Coates <sean@php.net> 
     86 * @copyright  2003-2006 PEAR <pear-group@php.net> 
     87 * @license    http://www.opensource.org/licenses/bsd-license.php BSD License 
     88 * @version    Release: @package_version@ 
     89 * @link       http://pear.php.net/package/Mail_mime 
     90 */ 
    9291class Mail_mimeDecode extends PEAR 
    9392{ 
    9493    /** 
    9594     * The raw email to decode 
     95     * 
    9696     * @var    string 
     97     * @access private 
    9798     */ 
    9899    var $_input; 
     
    100101    /** 
    101102     * The header part of the input 
     103     * 
    102104     * @var    string 
     105     * @access private 
    103106     */ 
    104107    var $_header; 
     
    106109    /** 
    107110     * The body part of the input 
     111     * 
    108112     * @var    string 
     113     * @access private 
    109114     */ 
    110115    var $_body; 
     
    112117    /** 
    113118     * If an error occurs, this is used to store the message 
     119     * 
    114120     * @var    string 
     121     * @access private 
    115122     */ 
    116123    var $_error; 
     
    119126     * Flag to determine whether to include bodies in the 
    120127     * returned object. 
     128     * 
    121129     * @var    boolean 
     130     * @access private 
    122131     */ 
    123132    var $_include_bodies; 
     
    125134    /** 
    126135     * Flag to determine whether to decode bodies 
     136     * 
    127137     * @var    boolean 
     138     * @access private 
    128139     */ 
    129140    var $_decode_bodies; 
     
    131142    /** 
    132143     * Flag to determine whether to decode headers 
     144     * 
    133145     * @var    boolean 
     146     * @access private 
    134147     */ 
    135148    var $_decode_headers; 
     
    835848 
    836849} // End of class 
    837 ?> 
  • program/lib/Mail/mimePart.php

    r15fee7b rab6f807  
    11<?php 
    2 // +-----------------------------------------------------------------------+ 
    3 // | Copyright (c) 2002-2003  Richard Heyes                                     | 
    4 // | All rights reserved.                                                  | 
    5 // |                                                                       | 
    6 // | Redistribution and use in source and binary forms, with or without    | 
    7 // | modification, are permitted provided that the following conditions    | 
    8 // | are met:                                                              | 
    9 // |                                                                       | 
    10 // | o Redistributions of source code must retain the above copyright      | 
    11 // |   notice, this list of conditions and the following disclaimer.       | 
    12 // | o Redistributions in binary form must reproduce the above copyright   | 
    13 // |   notice, this list of conditions and the following disclaimer in the | 
    14 // |   documentation and/or other materials provided with the distribution.| 
    15 // | o The names of the authors may not be used to endorse or promote      | 
    16 // |   products derived from this software without specific prior written  | 
    17 // |   permission.                                                         | 
    18 // |                                                                       | 
    19 // | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   | 
    20 // | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     | 
    21 // | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 
    22 // | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  | 
    23 // | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 
    24 // | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      | 
    25 // | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 
    26 // | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 
    27 // | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   | 
    28 // | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 
    29 // | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  | 
    30 // |                                                                       | 
    31 // +-----------------------------------------------------------------------+ 
    32 // | Author: Richard Heyes <richard@phpguru.org>                           | 
    33 // +-----------------------------------------------------------------------+ 
    34  
    352/** 
    36 * 
    37 *  Raw mime encoding class 
    38 * 
    39 * What is it? 
    40 *   This class enables you to manipulate and build 
    41 *   a mime email from the ground up. 
    42 * 
    43 * Why use this instead of mime.php? 
    44 *   mime.php is a userfriendly api to this class for 
    45 *   people who aren't interested in the internals of 
    46 *   mime mail. This class however allows full control 
    47 *   over the email. 
    48 * 
    49 * Eg. 
    50 * 
    51 * // Since multipart/mixed has no real body, (the body is 
    52 * // the subpart), we set the body argument to blank. 
    53 * 
    54 * $params['content_type'] = 'multipart/mixed'; 
    55 * $email = new Mail_mimePart('', $params); 
    56 * 
    57 * // Here we add a text part to the multipart we have 
    58 * // already. Assume $body contains plain text. 
    59 * 
    60 * $params['content_type'] = 'text/plain'; 
    61 * $params['encoding']     = '7bit'; 
    62 * $text = $email->addSubPart($body, $params); 
    63 * 
    64 * // Now add an attachment. Assume $attach is 
    65 * the contents of the attachment 
    66 * 
    67 * $params['content_type'] = 'application/zip'; 
    68 * $params['encoding']     = 'base64'; 
    69 * $params['disposition']  = 'attachment'; 
    70 * $params['dfilename']    = 'example.zip'; 
    71 * $attach =& $email->addSubPart($body, $params); 
    72 * 
    73 * // Now build the email. Note that the encode 
    74 * // function returns an associative array containing two 
    75 * // elements, body and headers. You will need to add extra 
    76 * // headers, (eg. Mime-Version) before sending. 
    77 * 
    78 * $email = $message->encode(); 
    79 * $email['headers'][] = 'Mime-Version: 1.0'; 
    80 * 
    81 * 
    82 * Further examples are available at http://www.phpguru.org 
    83 * 
    84 * TODO: 
    85 *  - Set encode() to return the $obj->encoded if encode() 
    86 *    has already been run. Unless a flag is passed to specifically 
    87 *    re-build the message. 
    88 * 
    89 * @author  Richard Heyes <richard@phpguru.org> 
    90 * @version $Revision$ 
    91 * @package Mail 
    92 */ 
    93  
     3 * The Mail_mimePart class is used to create MIME E-mail messages 
     4 * 
     5 * This class enables you to manipulate and build a mime email 
     6 * from the ground up. The Mail_Mime class is a userfriendly api 
     7 * to this class for people who aren't interested in the internals 
     8 * of mime mail. 
     9 * This class however allows full control over the email. 
     10 * 
     11 * Compatible with PHP versions 4 and 5 
     12 * 
     13 * LICENSE: This LICENSE is in the BSD license style. 
     14 * Copyright (c) 2002-2003, Richard Heyes <richard@phpguru.org> 
     15 * Copyright (c) 2003-2006, PEAR <pear-group@php.net> 
     16 * All rights reserved. 
     17 * 
     18 * Redistribution and use in source and binary forms, with or 
     19 * without modification, are permitted provided that the following 
     20 * conditions are met: 
     21 * 
     22 * - Redistributions of source code must retain the above copyright 
     23 *   notice, this list of conditions and the following disclaimer. 
     24 * - Redistributions in binary form must reproduce the above copyright 
     25 *   notice, this list of conditions and the following disclaimer in the 
     26 *   documentation and/or other materials provided with the distribution. 
     27 * - Neither the name of the authors, nor the names of its contributors  
     28 *   may be used to endorse or promote products derived from this  
     29 *   software without specific prior written permission. 
     30 * 
     31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
     32 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     33 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
     34 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
     35 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
     36 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
     37 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
     38 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
     39 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
     40 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
     41 * THE POSSIBILITY OF SUCH DAMAGE. 
     42 * 
     43 * @category   Mail 
     44 * @package    Mail_Mime 
     45 * @author     Richard Heyes  <richard@phpguru.org> 
     46 * @author     Cipriano Groenendal <cipri@php.net> 
     47 * @author     Sean Coates <sean@php.net> 
     48 * @copyright  2003-2006 PEAR <pear-group@php.net> 
     49 * @license    http://www.opensource.org/licenses/bsd-license.php BSD License 
     50 * @version    CVS: $Id$ 
     51 * @link       http://pear.php.net/package/Mail_mime 
     52 */ 
     53 
     54 
     55/** 
     56 * The Mail_mimePart class is used to create MIME E-mail messages 
     57 * 
     58 * This class enables you to manipulate and build a mime email 
     59 * from the ground up. The Mail_Mime class is a userfriendly api 
     60 * to this class for people who aren't interested in the internals 
     61 * of mime mail. 
     62 * This class however allows full control over the email. 
     63 * 
     64 * @category   Mail 
     65 * @package    Mail_Mime 
     66 * @author     Richard Heyes  <richard@phpguru.org> 
     67 * @author     Cipriano Groenendal <cipri@php.net> 
     68 * @author     Sean Coates <sean@php.net> 
     69 * @copyright  2003-2006 PEAR <pear-group@php.net> 
     70 * @license    http://www.opensource.org/licenses/bsd-license.php BSD License 
     71 * @version    Release: @package_version@ 
     72 * @link       http://pear.php.net/package/Mail_mime 
     73 */ 
    9474class Mail_mimePart { 
    9575 
    9676   /** 
    9777    * The encoding type of this part 
     78    * 
    9879    * @var string 
     80    * @access private 
    9981    */ 
    10082    var $_encoding; 
     
    10284   /** 
    10385    * An array of subparts 
     86    * 
    10487    * @var array 
     88    * @access private 
    10589    */ 
    10690    var $_subparts; 
     
    10892   /** 
    10993    * The output of this part after being built 
     94    * 
    11095    * @var string 
     96    * @access private 
    11197    */ 
    11298    var $_encoded; 
     
    114100   /** 
    115101    * Headers for this part 
     102    * 
    116103    * @var array 
     104    * @access private 
    117105    */ 
    118106    var $_headers; 
     
    120108   /** 
    121109    * The body of this part (not encoded) 
     110    * 
    122111    * @var string 
     112    * @access private 
    123113    */ 
    124114    var $_body; 
     
    235225            $encoded['body'] = '--' . $boundary . MAIL_MIMEPART_CRLF . 
    236226                               implode('--' . $boundary . MAIL_MIMEPART_CRLF, $subparts) . 
    237                                '--' . $boundary.'--' . MAIL_MIMEPART_CRLF; 
     227                               '--' . $boundary.'--' . MAIL_MIMEPART_CRLF . MAIL_MIMEPART_CRLF; 
    238228 
    239229        } else { 
     
    300290 
    301291    /** 
    302      * quoteadPrintableEncode() 
     292     * quotedPrintableEncode() 
    303293     * 
    304294     * Encodes data to quoted-printable standard. 
     
    319309        while(list(, $line) = each($lines)){ 
    320310 
    321             $linlen     = strlen($line); 
     311            $line    = preg_split('||', $line, -1, PREG_SPLIT_NO_EMPTY); 
     312            $linlen     = count($line); 
    322313            $newline = ''; 
    323314 
    324315            for ($i = 0; $i < $linlen; $i++) { 
    325                 $char = substr($line, $i, 1); 
     316                $char = $line[$i]; 
    326317                $dec  = ord($char); 
    327318 
     
    349340    } 
    350341} // End of class 
    351 ?> 
  • program/lib/html2text.inc

    r5cc4b13 rab6f807  
    113113        '/<script[^>]*>.*?<\/script>/i',         // <script>s -- which strip_tags supposedly has problems with 
    114114        //'/<!-- .* -->/',                         // Comments -- which strip_tags might have problem a with 
    115         '/<a [^>]*href="([^"]+)"[^>]*>(.+?)<\/a>/ie', // <a href=""> 
     115        '/<a [^>]*href=("|\')([^"\']+)\1[^>]*>(.+?)<\/a>/ie', // <a href=""> 
    116116        '/<h[123][^>]*>(.+?)<\/h[123]>/ie',      // H1 - H3 
    117117        '/<h[456][^>]*>(.+?)<\/h[456]>/ie',      // H4 - H6 
     
    162162        '',                                     // <script>s -- which strip_tags supposedly has problems with 
    163163        //'',                                  // Comments -- which strip_tags might have problem a with 
    164         '$this->_build_link_list("\\1", "\\2")', // <a href=""> 
     164        '$this->_build_link_list("\\2", "\\3")', // <a href=""> 
    165165        "strtoupper(\"\n\n\\1\n\n\")",          // H1 - H3 
    166166        "ucwords(\"\n\n\\1\n\")",               // H4 - H6 
  • program/steps/mail/sendmail.inc

    r5a6ad20 rab6f807  
    2525require_once('include/rcube_smtp.inc'); 
    2626require_once('lib/html2text.inc'); 
    27 require_once('Mail/mime.php'); 
     27require_once('lib/rc_mail_mime.inc'); 
    2828 
    2929 
     
    245245  $header_delm = "\n"; 
    246246 
    247 // create PEAR::Mail_mime instance 
    248247 
    249248$isHtmlVal = strtolower(get_input_value('_is_html', RCUBE_INPUT_POST)); 
    250249$isHtml = ($isHtmlVal == "1"); 
    251250 
    252 $MAIL_MIME = new Mail_mime($header_delm); 
     251// create extended PEAR::Mail_mime instance 
     252$MAIL_MIME = new rc_mail_mime($header_delm); 
    253253 
    254254// For HTML-formatted messages, construct the MIME message with both 
     
    276276if (is_array($_SESSION['compose']['attachments'])) 
    277277  foreach ($_SESSION['compose']['attachments'] as $attachment) 
    278     $MAIL_MIME->addAttachment($attachment['path'], $attachment['mimetype'], $attachment['name'], TRUE); 
    279  
    280    
     278    $MAIL_MIME->addAttachment($attachment['path'], $attachment['mimetype'], $attachment['name'], true, 'base64', 'attachment', $message_charset); 
     279 
    281280// add submitted attachments 
    282281if (is_array($_FILES['_attachments']['tmp_name'])) 
    283282  foreach ($_FILES['_attachments']['tmp_name'] as $i => $filepath) 
    284     $MAIL_MIME->addAttachment($filepath, $files['type'][$i], $files['name'][$i], TRUE); 
     283    $MAIL_MIME->addAttachment($filepath, $files['type'][$i], $files['name'][$i], true, 'base64', 'attachment', $message_charset); 
    285284 
    286285 
Note: See TracChangeset for help on using the changeset viewer.