Development

Changeset 33569

You must first sign up to be able to contribute.

Changeset 33569

Show
Ignore:
Timestamp:
10/25/12 11:31:11 (7 months ago)
Author:
fabien
Message:

[1.4] updated Swiftmailer to the latest 4.1 version (4.1.8)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift.php

    r32677 r33569  
    1919{ 
    2020   
     21  static $initialized = false; 
     22  static $initPath; 
     23   
    2124  /** Swift Mailer Version number generated during dist release process */ 
    22   const VERSION = '4.1.0-DEV'; 
     25  const VERSION = '4.1.8'; 
    2326   
    2427  /** 
     
    3033  { 
    3134    //Don't interfere with other autoloaders 
    32     if (0 !== strpos($class, 'Swift')) 
     35    if (0 !== strpos($class, 'Swift_')) 
    3336    { 
    34       return false
     37      return
    3538    } 
    3639 
     
    3942    if (!file_exists($path)) 
    4043    { 
    41       return false
     44      return
    4245    } 
    4346 
    44     require_once $path; 
     47    if (self::$initPath && !self::$initialized) 
     48    { 
     49      self::$initialized = true; 
     50      require self::$initPath; 
     51    } 
     52 
     53    require $path; 
    4554  } 
    4655   
     
    4958   *  
    5059   * This is designed to play nicely with other autoloaders. 
     60   * 
     61   * @param string $initPath The init script to load when autoloading the first Swift class 
    5162   */ 
    52   public static function registerAutoload(
     63  public static function registerAutoload($initPath = null
    5364  { 
     65    self::$initPath = $initPath; 
    5466    spl_autoload_register(array('Swift', 'autoload')); 
    5567  } 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Attachment.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/Attachment.php'; 
    12 //@require 'Swift/ByteStream/FileByteStream.php'; 
    13 //@require 'Swift/DependencyContainer.php'; 
    1411 
    1512/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/ByteStream/AbstractFilterableInputStream.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/InputByteStream.php'; 
    12 //@require 'Swift/Filterable.php'; 
    13 //@require 'Swift/StreamFilter.php'; 
    1411 
    1512/** 
     
    2421   
    2522  /** Write sequence */ 
    26   private $_sequence = 0; 
     23  protected $_sequence = 0; 
    2724   
    2825  /** StreamFilters */ 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/ByteStream/ArrayByteStream.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/InputByteStream.php'; 
    12 //@require 'Swift/OutputByteStream.php'; 
    1311 
    1412/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/ByteStream/FileByteStream.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/ByteStream/AbstractFilterableInputStream.php'; 
    12 //@require 'Swift/InputByteStream.php'; 
    13 //@require 'Swift/FileStream.php'; 
    14 //@require 'Swift/IoException.php'; 
    1511 
    1612/** 
     
    4238  /** If magic_quotes_runtime is on, this will be true */ 
    4339  private $_quotes = false; 
     40 
     41  /** If stream is seekable true/false, or null if not known */ 
     42  private $_seekable = null; 
    4443   
    4544  /** 
     
    5251    $this->_path = $path; 
    5352    $this->_mode = $writable ? 'w+b' : 'rb'; 
    54     $this->_quotes = get_magic_quotes_runtime(); 
     53     
     54    if (function_exists('get_magic_quotes_runtime') && @get_magic_quotes_runtime() == 1) 
     55    { 
     56      $this->_quotes = true; 
     57    } 
    5558  } 
    5659   
     
    8083      if ($this->_quotes) 
    8184      { 
    82         set_magic_quotes_runtime(0); 
     85        ini_set('magic_quotes_runtime', 0); 
    8386      } 
    8487      $bytes = fread($fp, $length); 
    8588      if ($this->_quotes) 
    8689      { 
    87         set_magic_quotes_runtime(1); 
     90        ini_set('magic_quotes_runtime', 1); 
    8891      } 
    8992      $this->_offset = ftell($fp); 
     
    9295    else 
    9396    { 
     97      $this->_resetReadHandle(); 
    9498      return false; 
    9599    } 
     
    105109    if (isset($this->_reader)) 
    106110    { 
    107       fseek($this->_reader, $byteOffset, SEEK_SET); 
     111      $this->_seekReadStreamToPosition($byteOffset); 
    108112    } 
    109113    $this->_offset = $byteOffset; 
     
    133137        throw new Swift_IoException( 
    134138          'Unable to open file for reading [' . $this->_path . ']' 
    135           ); 
    136       } 
    137       fseek($this->_reader, $this->_offset, SEEK_SET); 
     139        ); 
     140      } 
     141      if ($this->_offset <> 0) 
     142      { 
     143        $this->_getReadStreamSeekableStatus(); 
     144        $this->_seekReadStreamToPosition($this->_offset); 
     145      } 
    138146    } 
    139147    return $this->_reader; 
     
    149157        throw new Swift_IoException( 
    150158          'Unable to open file for writing [' . $this->_path . ']' 
    151           ); 
     159        ); 
    152160      } 
    153161    } 
    154162    return $this->_writer; 
    155   } 
    156    
    157   /** Force a reload of the resource for writing */ 
    158   private function _resetWriteHandle() 
    159   { 
    160     if (isset($this->_writer)) 
    161     { 
    162       fclose($this->_writer); 
    163       $this->_writer = null; 
    164     } 
    165163  } 
    166164   
     
    175173  } 
    176174   
     175  /** Check if ReadOnly Stream is seekable */ 
     176  private function _getReadStreamSeekableStatus() 
     177  { 
     178    $metas = stream_get_meta_data($this->_reader); 
     179    $this->_seekable = $metas['seekable']; 
     180  } 
     181   
     182  /** Streams in a readOnly stream ensuring copy if needed */ 
     183  private function _seekReadStreamToPosition($offset) 
     184  { 
     185    if ($this->_seekable===null) 
     186    { 
     187      $this->_getReadStreamSeekableStatus(); 
     188    } 
     189    if ($this->_seekable === false) 
     190    { 
     191      $currentPos = ftell($this->_reader); 
     192      if ($currentPos<$offset) 
     193      { 
     194        $toDiscard = $offset-$currentPos; 
     195        fread($this->_reader, $toDiscard); 
     196        return; 
     197      } 
     198      $this->_copyReadStream(); 
     199    } 
     200    fseek($this->_reader, $offset, SEEK_SET); 
     201  } 
     202   
     203  /** Copy a readOnly Stream to ensure seekability */ 
     204  private function _copyReadStream() 
     205  { 
     206    if ($tmpFile = fopen('php://temp/maxmemory:4096', 'w+b')) 
     207    { 
     208      /* We have opened a php:// Stream Should work without problem */ 
     209    }  
     210    elseif (function_exists('sys_get_temp_dir') && is_writable(sys_get_temp_dir()) && ($tmpFile = tmpfile()))  
     211    { 
     212      /* We have opened a tmpfile */ 
     213    }  
     214    else 
     215    { 
     216      throw new Swift_IoException('Unable to copy the file to make it seekable, sys_temp_dir is not writable, php://memory not available'); 
     217    } 
     218    $currentPos = ftell($this->_reader); 
     219    fclose($this->_reader); 
     220    $source = fopen($this->_path, 'rb'); 
     221    if (!$source) 
     222    { 
     223      throw new Swift_IoException('Unable to open file for copying [' . $this->_path . ']'); 
     224    } 
     225    fseek($tmpFile, 0, SEEK_SET); 
     226    while (!feof($source))  
     227    { 
     228      fwrite($tmpFile, fread($source, 4096)); 
     229    } 
     230    fseek($tmpFile, $currentPos, SEEK_SET); 
     231    fclose($source); 
     232    $this->_reader = $tmpFile; 
     233  } 
    177234} 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/CharacterReader.php

    r22246 r33569  
    3535  /** 
    3636   * Returns mapType 
    37    * @int mapType 
     37   * @return int mapType 
    3838   */ 
    3939  public function getMapType(); 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/CharacterReader/GenericFixedWidthReader.php

    r22246 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/CharacterReader.php'; 
    1211 
    1312/** 
     
    2120  implements Swift_CharacterReader 
    2221{ 
    23     
    2422  /** 
    2523   * The number of bytes in a single character. 
     
    2826   */ 
    2927  private $_width; 
    30    
     28 
    3129  /** 
    3230   * Creates a new GenericFixedWidthReader using $width bytes per character. 
     
    4947  public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars) 
    5048  { 
    51   $strlen = strlen($string); 
    52   // % and / are CPU intensive, so, maybe find a better way 
    53   $ignored = $strlen%$this->_width; 
    54   $ignoredChars = substr($string, - $ignored); 
    55   $currentMap = $this->_width; 
    56     return ($strlen - $ignored)/$this->_width; 
    57    
     49    $strlen = strlen($string); 
     50    // % and / are CPU intensive, so, maybe find a better way 
     51    $ignored = $strlen%$this->_width; 
     52    $ignoredChars = substr($string, - $ignored); 
     53    $currentMap = $this->_width; 
     54 
     55    return ($strlen - $ignored)/$this->_width; 
    5856  } 
    5957   
    6058  /** 
    6159   * Returns mapType 
    62    * @int mapType 
     60   * @return int mapType 
    6361   */ 
    6462  public function getMapType() 
    6563  { 
    66   return self::MAP_TYPE_FIXED_LEN; 
     64    return self::MAP_TYPE_FIXED_LEN; 
    6765  } 
    6866 
     
    7977  { 
    8078    $needed = $this->_width - $size; 
    81     return ($needed > -1) 
    82       ? $needed 
    83       : -1 
    84       ; 
     79 
     80    return ($needed > -1) ? $needed : -1; 
    8581  } 
    8682 
     
    9389    return $this->_width; 
    9490  } 
    95  
    9691} 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/CharacterReader/UsAsciiReader.php

    r22246 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/CharacterReader.php'; 
    1211 
    1312/** 
     
    2928  public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars) 
    3029  { 
    31   $strlen=strlen($string); 
    32   $ignoredChars=''; 
    33   for( $i = 0; $i < $strlen; ++$i) 
    34  
    35     if ($string[$i]>"\x07F") 
    36     { // Invalid char 
    37        $currentMap[$i+$startOffset]=$string[$i]; 
    38     } 
    39  
    40   return $strlen; 
     30    $strlen=strlen($string); 
     31    $ignoredChars=''; 
     32    for( $i = 0; $i < $strlen; ++$i) 
     33   
     34      if ($string[$i]>"\x07F") 
     35      { // Invalid char 
     36        $currentMap[$i+$startOffset]=$string[$i]; 
     37      } 
     38   
     39    return $strlen; 
    4140  } 
    4241   
    4342  /** 
    4443   * Returns mapType 
    45    * @int mapType 
     44   * @return int mapType 
    4645   */ 
    4746  public function getMapType() 
    4847  { 
    49   return self::MAP_TYPE_INVALID; 
     48    return self::MAP_TYPE_INVALID; 
    5049  } 
    5150  
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/CharacterReader/Utf8Reader.php

    r22246 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/CharacterReader.php'; 
    1211 
    1312/** 
     
    8786  public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars) 
    8887  { 
    89   if (!isset($currentMap['i']) || !isset($currentMap['p'])) 
    90  
    91     $currentMap['p'] = $currentMap['i'] = array(); 
    92     
    93   $strlen=strlen($string); 
    94   $charPos=count($currentMap['p']); 
    95   $foundChars=0; 
    96   $invalid=false; 
    97   for ($i=0; $i<$strlen; ++$i) 
    98  
    99     $char=$string[$i]; 
    100     $size=self::$s_length_map[$char]; 
    101     if ($size==0) 
    102     { 
    103       /* char is invalid, we must wait for a resync */ 
    104        $invalid=true; 
    105        continue; 
    106        } 
    107        else 
    108        { 
    109          if ($invalid==true) 
    110         
    111            /* We mark the chars as invalid and start a new char */ 
    112            $currentMap['p'][$charPos+$foundChars]=$startOffset+$i; 
    113            $currentMap['i'][$charPos+$foundChars]=true; 
    114            ++$foundChars; 
    115            $invalid=false; 
    116         
    117          if (($i+$size) > $strlen){ 
    118            $ignoredChars=substr($string, $i); 
    119            break; 
    120         
    121          for ($j=1; $j<$size; ++$j) 
    122         
     88    if (!isset($currentMap['i']) || !isset($currentMap['p'])) 
     89   
     90      $currentMap['p'] = $currentMap['i'] = array(); 
     91    
     92    $strlen=strlen($string); 
     93    $charPos=count($currentMap['p']); 
     94    $foundChars=0; 
     95    $invalid=false; 
     96    for ($i=0; $i<$strlen; ++$i) 
     97   
     98      $char=$string[$i]; 
     99      $size=self::$s_length_map[$char]; 
     100      if ($size==0) 
     101      { 
     102        /* char is invalid, we must wait for a resync */ 
     103        $invalid=true; 
     104        continue; 
     105       } 
     106       else 
     107       { 
     108         if ($invalid==true) 
     109        
     110           /* We mark the chars as invalid and start a new char */ 
     111           $currentMap['p'][$charPos+$foundChars]=$startOffset+$i; 
     112           $currentMap['i'][$charPos+$foundChars]=true; 
     113           ++$foundChars; 
     114           $invalid=false; 
     115        
     116         if (($i+$size) > $strlen){ 
     117           $ignoredChars=substr($string, $i); 
     118           break; 
     119        
     120         for ($j=1; $j<$size; ++$j) 
     121        
    123122          $char=$string[$i+$j]; 
    124123          if ($char>"\x7F" && $char<"\xC0") 
     
    132131            continue 2; 
    133132          } 
    134         
    135          /* Ok we got a complete char here */ 
    136          $lastChar=$currentMap['p'][$charPos+$foundChars]=$startOffset+$i+$size; 
    137          $i+=$j-1; 
    138          ++$foundChars; 
    139        } 
    140  
    141   return $foundChars; 
     133        
     134         /* Ok we got a complete char here */ 
     135         $currentMap['p'][$charPos+$foundChars]=$startOffset+$i+$size; 
     136         $i+=$j-1; 
     137         ++$foundChars; 
     138       } 
     139   
     140    return $foundChars; 
    142141  } 
    143142   
    144143  /** 
    145144   * Returns mapType 
    146    * @int mapType 
     145   * @return int mapType 
    147146   */ 
    148147  public function getMapType() 
    149148  { 
    150   return self::MAP_TYPE_POSITIONS; 
     149    return self::MAP_TYPE_POSITIONS; 
    151150  } 
    152151  
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/CharacterReaderFactory.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/CharacterReader.php'; 
    1211 
    1312/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/CharacterReaderFactory.php'; 
    1211 
    1312/** 
     
    2625   * @access private 
    2726   */ 
    28   private $_map = array(); 
     27  private static $_map = array(); 
    2928   
    3029  /** 
     
    3332   * @access private 
    3433   */ 
    35   private $_loaded = array(); 
     34  private static $_loaded = array(); 
    3635   
    3736  /** 
     
    4039  public function __construct() 
    4140  { 
     41    $this->init(); 
     42  } 
     43 
     44  public function __wakeup() 
     45  { 
     46    $this->init(); 
     47  } 
     48 
     49  public function init() 
     50  { 
     51    if(count(self::$_map) > 0) 
     52    { 
     53      return; 
     54    } 
     55     
    4256    $prefix = 'Swift_CharacterReader_'; 
    4357     
     
    5872     
    5973    //Utf-8 
    60     $this->_map['utf-?8'] = array( 
     74    self::$_map['utf-?8'] = array( 
    6175      'class' => $prefix . 'Utf8Reader', 
    6276      'constructor' => array() 
     
    6478     
    6579    //7-8 bit charsets 
    66     $this->_map['(us-)?ascii'] = $singleByte; 
    67     $this->_map['(iso|iec)-?8859-?[0-9]+'] = $singleByte; 
    68     $this->_map['windows-?125[0-9]'] = $singleByte; 
    69     $this->_map['cp-?[0-9]+'] = $singleByte; 
    70     $this->_map['ansi'] = $singleByte; 
    71     $this->_map['macintosh'] = $singleByte; 
    72     $this->_map['koi-?7'] = $singleByte; 
    73     $this->_map['koi-?8-?.+'] = $singleByte; 
    74     $this->_map['mik'] = $singleByte; 
    75     $this->_map['(cork|t1)'] = $singleByte; 
    76     $this->_map['v?iscii'] = $singleByte; 
     80    self::$_map['(us-)?ascii'] = $singleByte; 
     81    self::$_map['(iso|iec)-?8859-?[0-9]+'] = $singleByte; 
     82    self::$_map['windows-?125[0-9]'] = $singleByte; 
     83    self::$_map['cp-?[0-9]+'] = $singleByte; 
     84    self::$_map['ansi'] = $singleByte; 
     85    self::$_map['macintosh'] = $singleByte; 
     86    self::$_map['koi-?7'] = $singleByte; 
     87    self::$_map['koi-?8-?.+'] = $singleByte; 
     88    self::$_map['mik'] = $singleByte; 
     89    self::$_map['(cork|t1)'] = $singleByte; 
     90    self::$_map['v?iscii'] = $singleByte; 
    7791     
    7892    //16 bits 
    79     $this->_map['(ucs-?2|utf-?16)'] = $doubleByte; 
     93    self::$_map['(ucs-?2|utf-?16)'] = $doubleByte; 
    8094     
    8195    //32 bits 
    82     $this->_map['(ucs-?4|utf-?32)'] = $fourBytes; 
     96    self::$_map['(ucs-?4|utf-?32)'] = $fourBytes; 
    8397     
    8498    //Fallback 
    85     $this->_map['.*'] = $singleByte; 
     99    self::$_map['.*'] = $singleByte; 
    86100  } 
    87101   
     
    94108  { 
    95109    $charset = trim(strtolower($charset)); 
    96     foreach ($this->_map as $pattern => $spec) 
     110    foreach (self::$_map as $pattern => $spec) 
    97111    { 
    98112      $re = '/^' . $pattern . '$/D'; 
    99113      if (preg_match($re, $charset)) 
    100114      { 
    101         if (!array_key_exists($pattern, $this->_loaded)) 
     115        if (!array_key_exists($pattern, self::$_loaded)) 
    102116        { 
    103117          $reflector = new ReflectionClass($spec['class']); 
     
    110124            $reader = $reflector->newInstance(); 
    111125          } 
    112           $this->_loaded[$pattern] = $reader; 
     126          self::$_loaded[$pattern] = $reader; 
    113127        } 
    114         return $this->_loaded[$pattern]; 
     128        return self::$_loaded[$pattern]; 
    115129      } 
    116130    } 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/CharacterStream/ArrayCharacterStream.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/CharacterStream.php'; 
    12 //@require 'Swift/OutputByteStream.php'; 
    1311 
    1412 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/CharacterStream/NgCharacterStream.php

    r22246 r33569  
    1919 */ 
    2020 
    21 //@require 'Swift/CharacterStream.php'; 
    22 //@require 'Swift/OutputByteStream.php'; 
    2321 
    2422 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/DependencyContainer.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/DependencyException.php'; 
    1211 
    1312/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/DependencyException.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/SwiftException.php'; 
    1211 
    1312/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/EmbeddedFile.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/Attachment.php'; 
    12 //@require 'Swift/DependencyContainer.php'; 
    13 //@require 'Swift/ByteStream/FileByteStream.php'; 
    1411 
    1512/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Encoder.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/CharsetObserver.php'; 
    1211 
    1312/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Encoder/Base64Encoder.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Encoder.php'; 
    1211 
    1312/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Encoder/QpEncoder.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Encoder.php'; 
    12 //@require 'Swift/CharacterStream.php'; 
    1311 
    1412/** 
     
    9694    ); 
    9795 
     96  protected static $_safeMapShare = array(); 
     97 
    9898  /** 
    9999   * A map of non-encoded ascii characters. 
     
    101101   * @access protected 
    102102   */ 
    103   protected static $_safeMap = array(); 
     103  protected $_safeMap = array(); 
    104104 
    105105  /** 
     
    112112  { 
    113113    $this->_charStream = $charStream; 
    114     if (empty(self::$_safeMap)) 
    115     { 
    116       foreach (array_merge( 
    117         array(0x09, 0x20), range(0x21, 0x3C), range(0x3E, 0x7E)) as $byte) 
    118       { 
    119         self::$_safeMap[$byte] = chr($byte); 
    120       } 
     114    if(!isset(self::$_safeMapShare[$this->getSafeMapShareId()])) 
     115    { 
     116      $this->initSafeMap(); 
     117      self::$_safeMapShare[$this->getSafeMapShareId()] = $this->_safeMap; 
     118    } 
     119    else 
     120    { 
     121      $this->_safeMap = self::$_safeMapShare[$this->getSafeMapShareId()]; 
    121122    } 
    122123    $this->_filter = $filter; 
     124  } 
     125 
     126  public function __sleep() 
     127  { 
     128    return array('_charStream', '_filter'); 
     129  } 
     130 
     131  public function __wakeup() 
     132  { 
     133    if(!isset(self::$_safeMapShare[$this->getSafeMapShareId()])) 
     134    { 
     135      $this->initSafeMap(); 
     136      self::$_safeMapShare[$this->getSafeMapShareId()] = $this->_safeMap; 
     137    } 
     138    else 
     139    { 
     140      $this->_safeMap = self::$_safeMapShare[$this->getSafeMapShareId()]; 
     141    } 
     142  } 
     143 
     144  protected function getSafeMapShareId() 
     145  { 
     146    return get_class($this); 
     147  } 
     148 
     149  protected function initSafeMap() 
     150  { 
     151    foreach (array_merge( 
     152      array(0x09, 0x20), range(0x21, 0x3C), range(0x3E, 0x7E)) as $byte) 
     153    { 
     154      $this->_safeMap[$byte] = chr($byte); 
     155    } 
    123156  } 
    124157 
     
    216249    foreach ($bytes as $b) 
    217250    { 
    218       if (isset(self::$_safeMap[$b])) 
    219       { 
    220         $ret .= self::$_safeMap[$b]; 
     251      if (isset($this->_safeMap[$b])) 
     252      { 
     253        $ret .= $this->_safeMap[$b]; 
    221254        ++$size; 
    222255      } 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Encoder/Rfc2231Encoder.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Encoder.php'; 
    12 //@require 'Swift/CharacterStream.php'; 
    1311 
    1412/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Encoding.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/DependencyContainer.php'; 
    1211 
    1312/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Events/CommandEvent.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Events/EventObject.php'; 
    12 //@require 'Swift/Transport.php'; 
    1311 
    1412/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Events/CommandListener.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Events/EventListener.php'; 
    12 //@require 'Swift/Events/CommandEvent.php'; 
    1311 
    1412/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Events/EventDispatcher.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Events/EventListener.php'; 
    12 //@require 'Swift/Event.php'; 
    1311 
    1412/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Events/EventObject.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Events/Event.php'; 
    1211 
    1312/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Events/ResponseEvent.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Events/EventObject.php'; 
    1211 
    1312/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Events/ResponseListener.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Events/EventListener.php'; 
    12 //@require 'Swift/Events/ResponseEvent.php'; 
    1311 
    1412/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Events/SendEvent.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Events/EventObject.php'; 
    1211 
    1312/** 
     
    3938   
    4039  /** 
    41    * The Transport used in sending. 
    42    * @var Swift_Transport 
    43    */ 
    44   private $_transport; 
    45    
    46   /** 
    4740   * Any recipients which failed after sending. 
    4841   * @var string[] 
    4942   */ 
    50   private $failedRecipients = array(); 
     43  private $_failedRecipients = array(); 
    5144   
    5245  /** 
     
    5447   * @var int 
    5548   */ 
    56   private $result; 
     49  private $_result; 
    5750   
    5851  /** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Events/SendListener.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Events/EventListener.php'; 
    12 //@require 'Swift/Events/SendEvent.php'; 
    1311 
    1412/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Events/SimpleEventDispatcher.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Events/EventDispatcher.php'; 
    12 //@require 'Swift/Events/EventListener.php'; 
    13 //@require 'Swift/Events/EventObject.php'; 
    14 //@require 'Swift/Events/CommandEvent.php'; 
    15 //@require 'Swift/Events/ResponseEvent.php'; 
    16 //@require 'Swift/Events/SendEvent.php'; 
    17 //@require 'Swift/Events/TransportChangeEvent.php'; 
    18 //@require 'Swift/Events/TransportExceptionEvent.php'; 
    1911 
    2012/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Events/TransportChangeEvent.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Events/EventObject.php'; 
    1211 
    1312/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Events/TransportChangeListener.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Events/EventListener.php'; 
    12 //@require 'Swift/Events/TransportChangeEvent.php'; 
    1311 
    1412/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Events/TransportExceptionEvent.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Events/EventObject.php'; 
    12 //@require 'Swift/TransportException.php'; 
    1311 
    1412/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Events/TransportExceptionListener.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Events/EventListener.php'; 
    12 //@require 'Swift/Events/TransportExceptionEvent.php'; 
    1311 
    1412/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/FailoverTransport.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Transport/FailoverTransport.php'; 
    12 //@require 'Swift/DependencyContainer.php'; 
    1311 
    1412/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/FileSpool.php

    r23762 r33569  
    1313 * @package Swift 
    1414 * @author  Fabien Potencier 
     15 * @author Xavier De Cock <xdecock@gmail.com> 
    1516 */ 
    1617class Swift_FileSpool extends Swift_ConfigurableSpool 
     
    2021   
    2122  /** 
     23   * File WriteRetry Limit 
     24   * @var int 
     25   */ 
     26  private $_retryLimit=10; 
     27   
     28  /** 
    2229   * Create a new FileSpool. 
    2330   * @param string $path 
     31   * @throws Swift_IoException 
    2432   */ 
    2533  public function __construct($path) 
     
    2937    if (!file_exists($this->_path)) 
    3038    { 
    31       mkdir($this->_path, 0777, true); 
     39      if (!mkdir($this->_path, 0777, true)) 
     40      { 
     41        throw new Swift_IoException('Unable to create Path ['.$this->_path.']'); 
     42      } 
    3243    } 
    3344  } 
     
    5869   
    5970  /** 
     71   * Allow to manage the enqueuing retry limit. 
     72   * Default, is ten and allows over 64^20 different fileNames  
     73   *  
     74   * @param integer $limit 
     75   */ 
     76  public function setRetryLimit($limit) 
     77  { 
     78    $this->_retryLimit=$limit; 
     79  } 
     80   
     81  /** 
    6082   * Queues a message. 
    6183   * @param Swift_Mime_Message $message The message to store 
     84   * @return boolean 
     85   * @throws Swift_IoException 
    6286   */ 
    6387  public function queueMessage(Swift_Mime_Message $message) 
    6488  { 
    6589    $ser = serialize($message); 
     90    $fileName=$this->_path.'/'.$this->getRandomString(10); 
     91    for ($i = 0; $i < $this->_retryLimit; ++$i)  
     92    { 
     93      /* We try an exclusive creation of the file 
     94       * This is an atomic operation, it avoid locking mechanism 
     95       */ 
     96      $fp = @fopen($fileName.'.message', 'x'); 
     97      if (false !== $fp) 
     98      { 
     99        if (false === fwrite($fp, $ser)) 
     100        { 
     101          return false; 
     102        } 
     103 
     104        return fclose($fp); 
     105      } 
     106      else 
     107      { 
     108        /* The file allready exists, we try a longer fileName 
     109         */ 
     110        $fileName.=$this->getRandomString(1); 
     111      } 
     112    } 
    66113     
    67     file_put_contents($this->_path.'/'.md5($ser.uniqid()).'.message', $ser); 
     114    throw new Swift_IoException('Unable to create a file for enqueuing Message'); 
     115  } 
     116   
     117  /** 
     118   * Execute a recovery if for anyreason a process is sending for too long 
     119   *  
     120   * @param int $timeout in second Defaults is for very slow smtp responses 
     121   */ 
     122  public function recover($timeout=900) 
     123  { 
     124    foreach (new DirectoryIterator($this->_path) as $file) 
     125    { 
     126      $file = $file->getRealPath(); 
     127 
     128      if (substr($file, -16)=='.message.sending') 
     129      { 
     130        $lockedtime=filectime($file); 
     131        if ((time()-$lockedtime)>$timeout)  
     132        { 
     133          rename($file, substr($file, 0, -8)); 
     134        } 
     135      } 
     136    }     
    68137  } 
    69138   
     
    90159      $file = $file->getRealPath(); 
    91160 
    92       if (!strpos($file, '.message')
     161      if (substr($file, -8) != '.message'
    93162      { 
    94163        continue; 
    95164      } 
    96165 
    97       $message = unserialize(file_get_contents($file)); 
    98  
    99       $count += $transport->send($message, $failedRecipients); 
    100  
    101       unlink($file); 
     166      /* We try a rename, it's an atomic operation, and avoid locking the file */ 
     167      if (rename($file, $file.'.sending'))  
     168      { 
     169        $message = unserialize(file_get_contents($file.'.sending')); 
     170 
     171        $count += $transport->send($message, $failedRecipients); 
     172 
     173        unlink($file.'.sending'); 
     174      } 
     175      else  
     176      { 
     177        /* This message has just been catched by another process */ 
     178        continue; 
     179      } 
    102180 
    103181      if ($this->getMessageLimit() && $count >= $this->getMessageLimit()) 
     
    114192    return $count; 
    115193  } 
     194   
     195  /** 
     196   * Returns a random string needed to generate a fileName for the queue. 
     197   * @param int $count 
     198   */ 
     199  protected function getRandomString($count) { 
     200    // This string MUST stay FS safe, avoid special chars 
     201    $base="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-."; 
     202    $ret=''; 
     203    $strlen=strlen($base); 
     204    for ($i=0; $i<$count; ++$i)  
     205    { 
     206      $ret.=$base[((int)rand(0,$strlen-1))]; 
     207    } 
     208    return $ret; 
     209  } 
    116210} 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/FileStream.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/OutputByteStream.php'; 
    1211 
    1312/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Filterable.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/StreamFilter.php'; 
    1211 
    1312/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Image.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Image.php'; 
    12 //@require 'Swift/ByteStream/FileByteStream.php'; 
    1311 
    1412/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/IoException.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/SwiftException.php'; 
    1211 
    1312/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/KeyCache.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/InputByteStream.php'; 
    12 //@require 'Swift/OutputByteStream.php'; 
    1311 
    1412/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/KeyCache/ArrayKeyCache.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/KeyCache.php'; 
    12 //@require 'Swift/KeyCacheInputStream.php'; 
    13 //@require 'Swift/InputByteStream.php'; 
    14 //@require 'Swift/OutputByteStrean.php'; 
    15 //@require 'Swift/SwiftException.php'; 
    1611 
    1712/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/KeyCache/DiskKeyCache.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/KeyCache.php'; 
    12 //@require 'Swift/KeyCacheInputStream.php'; 
    13 //@require 'Swift/InputByteStream.php'; 
    14 //@require 'Swift/OutputByteStrean.php'; 
    15 //@require 'Swift/SwiftException.php'; 
    16 //@require 'Swift/IoException.php'; 
    1711 
    1812/** 
     
    3024  /** Signal to place pointer at end of file */ 
    3125  const POSITION_END = 1; 
     26   
     27  /** Signal to leave pointer in whatever position it currently is */ 
     28  const POSITION_CURRENT = 2; 
    3229 
    3330  /** 
     
    6966    $this->_stream = $stream; 
    7067    $this->_path = $path; 
    71     $this->_quotes = get_magic_quotes_runtime(); 
     68 
     69    if (function_exists('get_magic_quotes_runtime') && @get_magic_quotes_runtime() == 1) 
     70    { 
     71      $this->_quotes = true; 
     72    } 
    7273  } 
    7374 
     
    100101    } 
    101102    fwrite($fp, $string); 
     103    $this->_freeHandle($nsKey, $itemKey); 
    102104  } 
    103105 
     
    134136      fwrite($fp, $bytes); 
    135137    } 
     138    $this->_freeHandle($nsKey, $itemKey); 
    136139  } 
    137140 
     
    172175      if ($this->_quotes) 
    173176      { 
    174         set_magic_quotes_runtime(0); 
     177        ini_set('magic_quotes_runtime', 0); 
    175178      } 
    176179      $str = ''; 
     
    181184      if ($this->_quotes) 
    182185      { 
    183         set_magic_quotes_runtime(1); 
    184       } 
     186        ini_set('magic_quotes_runtime', 1); 
     187      } 
     188      $this->_freeHandle($nsKey, $itemKey); 
    185189      return $str; 
    186190    } 
     
    200204      if ($this->_quotes) 
    201205      { 
    202         set_magic_quotes_runtime(0); 
     206        ini_set('magic_quotes_runtime', 0); 
    203207      } 
    204208      while (!feof($fp) && false !== $bytes = fread($fp, 8192)) 
     
    208212      if ($this->_quotes) 
    209213      { 
    210         set_magic_quotes_runtime(1); 
    211       } 
     214        ini_set('magic_quotes_runtime', 1); 
     215      } 
     216      $this->_freeHandle($nsKey, $itemKey); 
    212217    } 
    213218  } 
     
    233238    if ($this->hasKey($nsKey, $itemKey)) 
    234239    { 
    235       $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_END); 
    236       fclose($fp); 
     240      $this->_freeHandle($nsKey, $itemKey); 
    237241      unlink($this->_path . '/' . $nsKey . '/' . $itemKey); 
    238242    } 
    239     unset($this->_keys[$nsKey][$itemKey]); 
    240243  } 
    241244 
     
    252255        $this->clearKey($nsKey, $itemKey); 
    253256      } 
    254       rmdir($this->_path . '/' . $nsKey); 
     257      if (is_dir($this->_path . '/' . $nsKey)) 
     258      { 
     259        rmdir($this->_path . '/' . $nsKey); 
     260      } 
    255261      unset($this->_keys[$nsKey]); 
    256262    } 
     
    287293  private function _getHandle($nsKey, $itemKey, $position) 
    288294  { 
    289     if (!isset($this->_keys[$nsKey]) || !array_key_exists($itemKey, $this->_keys[$nsKey])) 
    290     { 
    291       $fp = fopen($this->_path . '/' . $nsKey . '/' . $itemKey, 'w+b'); 
     295    if (!isset($this->_keys[$nsKey][$itemKey])) 
     296    { 
     297      $openMode = $this->hasKey($nsKey, $itemKey) 
     298        ? 'r+b' 
     299        : 'w+b' 
     300        ; 
     301      $fp = fopen($this->_path . '/' . $nsKey . '/' . $itemKey, $openMode); 
    292302      $this->_keys[$nsKey][$itemKey] = $fp; 
    293303    } 
     
    296306      fseek($this->_keys[$nsKey][$itemKey], 0, SEEK_SET); 
    297307    } 
    298     else 
     308    elseif (self::POSITION_END == $position) 
    299309    { 
    300310      fseek($this->_keys[$nsKey][$itemKey], 0, SEEK_END); 
     
    302312    return $this->_keys[$nsKey][$itemKey]; 
    303313  } 
     314   
     315  private function _freeHandle($nsKey, $itemKey) 
     316  { 
     317    $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_CURRENT); 
     318    fclose($fp); 
     319    $this->_keys[$nsKey][$itemKey] = null; 
     320  } 
    304321 
    305322  /** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/KeyCache/KeyCacheInputStream.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/KeyCache.php'; 
    12 //@require 'Swift/InputByteStream.php'; 
    1311 
    1412/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/KeyCache/NullKeyCache.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/KeyCache.php'; 
    12 //@require 'Swift/KeyCacheInputStream.php'; 
    13 //@require 'Swift/InputByteStream.php'; 
    14 //@require 'Swift/OutputByteStrean.php'; 
    1511 
    1612/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/KeyCache.php'; 
    12 //@require 'Swift/KeyCacheInputStream.php'; 
    1311 
    1412/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/LoadBalancedTransport.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Transport/LoadBalancedTransport.php'; 
    12 //@require 'Swift/DependencyContainer.php'; 
    1311 
    1412/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/MailTransport.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Transport/MailTransport.php'; 
    12 //@require 'Swift/DependencyContainer.php'; 
    1311 
    1412/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mailer.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Transport.php'; 
    12 //@require 'Swift/Mime/Message.php'; 
    13 //@require 'Swift/Mailer/RecipientIterator.php'; 
    14 //@require 'Swift/Events/EventListener.php'; 
    1511 
    1612/** 
     
    4642    return new self($transport); 
    4743  } 
    48    
     44 
     45  /** 
     46   * Create a new class instance of one if the message services 
     47   * For example 'mimepart' would create a 'message.mimepart' instance 
     48   * 
     49   * @param string $service 
     50   * @return object 
     51   */ 
     52  public function createMessage($service = 'message') 
     53  { 
     54    return Swift_DependencyContainer::getInstance() 
     55      ->lookup('message.'.$service); 
     56  } 
     57 
    4958  /** 
    5059   * Send the given Message like it would be sent in a mail client. 
     
    5362   * recipients this message was sent to. 
    5463   *  
    55    * If you need to send to each recipient without disclosing details about the 
    56    * other recipients see {@link batchSend()}. 
    57    *  
    58    * Recipient/sender data will be retreived from the Message object. 
     64   * Recipient/sender data will be retrieved from the Message object. 
    5965   *  
    6066   * The return value is the number of recipients who were accepted for 
     
    6470   * @param array &$failedRecipients, optional 
    6571   * @return int 
    66    * @see batchSend() 
    6772   */ 
    6873  public function send(Swift_Mime_Message $message, &$failedRecipients = null) 
     
    7580    } 
    7681     
    77     return $this->_transport->send($message, $failedRecipients); 
    78   } 
    79    
    80   /** 
    81    * Send the given Message to all recipients individually. 
    82    *  
    83    * This differs from {@link send()} in the way headers are presented to the 
    84    * recipient.  The only recipient in the "To:" field will be the individual 
    85    * recipient it was sent to. 
    86    *  
    87    * If an iterator is provided, recipients will be read from the iterator 
    88    * one-by-one, otherwise recipient data will be retreived from the Message 
    89    * object. 
    90    *  
    91    * Sender information is always read from the Message object. 
    92    *  
    93    * The return value is the number of recipients who were accepted for 
    94    * delivery. 
    95    *  
    96    * @param Swift_Mime_Message $message 
    97    * @param array &$failedRecipients, optional 
    98    * @param Swift_Mailer_RecipientIterator $it, optional 
    99    * @return int 
    100    * @see send() 
    101    */ 
    102   public function batchSend(Swift_Mime_Message $message, 
    103     &$failedRecipients = null, 
    104     Swift_Mailer_RecipientIterator $it = null) 
    105   { 
    106     $failedRecipients = (array) $failedRecipients; 
     82    $sent = 0; 
    10783     
    108     $sent = 0; 
    109     $to = $message->getTo(); 
    110     $cc = $message->getCc(); 
    111     $bcc = $message->getBcc(); 
    112      
    113     if (!empty($cc)) 
     84    try 
    11485    { 
    115       $message->setCc(array()); 
     86      $sent = $this->_transport->send($message, $failedRecipients); 
    11687    } 
    117     if (!empty($bcc)
     88    catch (Swift_RfcComplianceException $e
    11889    { 
    119       $message->setBcc(array()); 
    120     } 
    121      
    122     //Use an iterator if set 
    123     if (isset($it)) 
    124     { 
    125       while ($it->hasNext()) 
     90      foreach ($message->getTo() as $address => $name) 
    12691      { 
    127         $message->setTo($it->nextRecipient()); 
    128         $sent += $this->send($message, $failedRecipients); 
     92        $failedRecipients[] = $address; 
    12993      } 
    130     } 
    131     else 
    132     { 
    133       foreach ($to as $address => $name) 
    134       { 
    135         $message->setTo(array($address => $name)); 
    136         $sent += $this->send($message, $failedRecipients); 
    137       } 
    138     } 
    139      
    140     $message->setTo($to); 
    141      
    142     if (!empty($cc)) 
    143     { 
    144       $message->setCc($cc); 
    145     } 
    146     if (!empty($bcc)) 
    147     { 
    148       $message->setBcc($bcc); 
    14994    } 
    15095     
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mailer/ArrayRecipientIterator.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mailer/RecipientIterator.php'; 
    1211 
    1312/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Message.php

    r22246 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/SimpleMessage.php'; 
    12 //@require 'Swift/MimePart.php'; 
    13 //@require 'Swift/DependencyContainer.php'; 
    1411 
    1512/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mime/Attachment.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/SimpleMimeEntity.php'; 
    12 //@require 'Swift/Mime/ContentEncoder.php'; 
    13 //@require 'Swift/Mime/HeaderSet.php'; 
    14 //@require 'Swift/FileStream.php'; 
    15 //@require 'Swift/KeyCache.php'; 
    1611 
    1712/** 
     
    3227   * @param Swift_Mime_ContentEncoder $encoder 
    3328   * @param Swift_KeyCache $cache 
     29   * @param Swift_Mime_Grammar $grammar 
    3430   * @param array $mimeTypes optional 
    3531   */ 
    3632  public function __construct(Swift_Mime_HeaderSet $headers, 
    3733    Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, 
    38     $mimeTypes = array()) 
     34    Swift_Mime_Grammar $grammar, $mimeTypes = array()) 
    3935  { 
    40     parent::__construct($headers, $encoder, $cache); 
     36    parent::__construct($headers, $encoder, $cache, $grammar); 
    4137    $this->setDisposition('attachment'); 
    4238    $this->setContentType('application/octet-stream'); 
     
    6763   * Set the Content-Disposition of this attachment. 
    6864   * @param string $disposition 
     65   * @return Swift_Mime_Attachment 
    6966   */ 
    7067  public function setDisposition($disposition) 
     
    9188   * Set the filename of this attachment. 
    9289   * @param string $filename 
     90   * @return Swift_Mime_Attachment 
    9391   */ 
    9492  public function setFilename($filename) 
     
    111109   * Set the file size of this attachment. 
    112110   * @param int $size 
     111   * @return Swift_Mime_Attachment 
    113112   */ 
    114113  public function setSize($size) 
     
    122121   * @param Swift_FileStream $file 
    123122   * @param string $contentType optional 
     123   * @return Swift_Mime_Attachment 
    124124   */ 
    125125  public function setFile(Swift_FileStream $file, $contentType = null) 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mime/ContentEncoder.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Encoder.php'; 
    12 //@require 'Swift/InputByteStream.php'; 
    13 //@require 'Swift/OutputByteStream.php'; 
    1411 
    1512/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/ContentEncoder.php'; 
    12 //@require 'Swift/Encoder/Base64Encoder.php'; 
    13 //@require 'Swift/InputByteStream.php'; 
    14 //@require 'Swift/OutputByteStream.php'; 
    1511 
    1612/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mime/ContentEncoder/PlainContentEncoder.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/ContentEncoder.php'; 
    12 //@require 'Swift/InputByteStream.php'; 
    13 //@require 'Swift/OutputByteStream.php'; 
    1411 
    1512/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php

    r23762 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/ContentEncoder.php'; 
    12 //@require 'Swift/Encoder/QpEncoder.php'; 
    13 //@require 'Swift/InputByteStrean.php'; 
    14 //@require 'Swift/OutputByteStream.php'; 
    15 //@require 'Swift/CharacterStream.php'; 
    1611 
    1712/** 
     
    2520{ 
    2621 
     22  protected $_dotEscape; 
     23 
    2724  /** 
    2825   * Creates a new QpContentEncoder for the given CharacterStream. 
    2926   * @param Swift_CharacterStream $charStream to use for reading characters 
    3027   * @param Swift_StreamFilter $filter if canonicalization should occur 
     28   * @param boolean $dotEscape if dot stuffing workaround must be enabled 
    3129   */ 
    3230  public function __construct(Swift_CharacterStream $charStream, 
    33     Swift_StreamFilter $filter = null
     31    Swift_StreamFilter $filter = null, $dotEscape=false
    3432  { 
     33    $this->_dotEscape = $dotEscape; 
    3534    parent::__construct($charStream, $filter); 
     35  } 
     36 
     37  public function __sleep() 
     38  { 
     39    return array('_charStream', '_filter', '_dotEscape'); 
     40  } 
     41 
     42  protected function getSafeMapShareId() 
     43  { 
     44    return get_class($this).($this->_dotEscape ? '.dotEscape' : ''); 
     45  } 
     46 
     47  protected function initSafeMap() 
     48  { 
     49    parent::initSafeMap(); 
     50    if ($this->_dotEscape) { 
     51      /* Encode . as =2e for buggy remote servers */ 
     52      unset($this->_safeMap[0x2e]); 
     53    }     
    3654  } 
    3755 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mime/EmbeddedFile.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/Attachment.php'; 
    12 //@require 'Swift/Mime/ContentEncoder.php'; 
    13 //@require 'Swift/KeyCache.php'; 
    14 //@require 
    1511 
    1612/** 
     
    2824   * @param Swift_Mime_ContentEncoder $encoder 
    2925   * @param Swift_KeyCache $cache 
     26   * @param Swift_Mime_Grammar $grammar 
    3027   * @param array $mimeTypes optional 
    3128   */ 
    3229  public function __construct(Swift_Mime_HeaderSet $headers, 
    3330    Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, 
    34     $mimeTypes = array()) 
     31    Swift_Mime_Grammar $grammar, $mimeTypes = array()) 
    3532  { 
    36     parent::__construct($headers, $encoder, $cache, $mimeTypes); 
     33    parent::__construct($headers, $encoder, $cache, $grammar, $mimeTypes); 
    3734    $this->setDisposition('inline'); 
    3835    $this->setId($this->getId()); 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mime/EncodingObserver.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/ContentEncoder.php'; 
    1211 
    1312/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mime/HeaderEncoder.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Encoder.php'; 
    1211 
    1312/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mime/HeaderEncoder/Base64HeaderEncoder.php

    r21985 r33569  
    3333    return 'B'; 
    3434  } 
    35    
     35 
     36 
     37  /** 
     38   * Takes an unencoded string and produces a Base64 encoded string from it. 
     39   * If the charset is iso-2022-jp, it uses mb_encode_mimeheader instead of 
     40   * default encodeString, otherwise pass to the parent method. 
     41   * @param string $string to encode 
     42   * @param int $firstLineOffset 
     43   * @param int $maxLineLength, optional, 0 indicates the default of 76 bytes 
     44   * @param string $charset 
     45   * @return string 
     46   */ 
     47  public function encodeString($string, $firstLineOffset = 0, 
     48    $maxLineLength = 0, $charset = 'utf-8') 
     49  { 
     50    if (strtolower($charset) === 'iso-2022-jp') 
     51    { 
     52       $old = mb_internal_encoding(); 
     53        mb_internal_encoding('utf-8'); 
     54        $newstring = mb_encode_mimeheader($string, $charset, $this->getName(), "\r\n"); 
     55        mb_internal_encoding($old); 
     56        return $newstring; 
     57    } 
     58    return parent::encodeString($string, $firstLineOffset, $maxLineLength); 
     59  } 
     60 
    3661} 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php

    r21985 r33569  
    2323{ 
    2424 
    25   private static $_headerSafeMap = array(); 
    26  
    2725  /** 
    2826   * Creates a new QpHeaderEncoder for the given CharacterStream. 
     
    3230  { 
    3331    parent::__construct($charStream); 
    34     if (empty(self::$_headerSafeMap)) 
     32  } 
     33   
     34  protected function initSafeMap() 
     35  { 
     36    foreach (array_merge( 
     37      range(0x61, 0x7A), range(0x41, 0x5A), 
     38      range(0x30, 0x39), array(0x20, 0x21, 0x2A, 0x2B, 0x2D, 0x2F) 
     39      ) as $byte) 
    3540    { 
    36       foreach (array_merge( 
    37         range(0x61, 0x7A), range(0x41, 0x5A), 
    38         range(0x30, 0x39), array(0x20, 0x21, 0x2A, 0x2B, 0x2D, 0x2F) 
    39         ) as $byte) 
    40       { 
    41         self::$_headerSafeMap[$byte] = chr($byte); 
    42       } 
     41      $this->_safeMap[$byte] = chr($byte); 
    4342    } 
    4443  } 
     
    6261   */ 
    6362  public function encodeString($string, $firstLineOffset = 0, 
    64     $maxLineLength = 0
     63    $maxLineLength = 0, $charst = 'utf-8'
    6564  { 
    6665    return str_replace(array(' ', '=20', "=\r\n"), array('_', '_', "\r\n"), 
     
    6968  } 
    7069 
    71   // -- Overridden points of extension 
    72  
    73   /** 
    74    * Encode the given byte array into a verbatim QP form. 
    75    * @param int[] $bytes 
    76    * @return string 
    77    * @access protected 
    78    */ 
    79   protected function _encodeByteSequence(array $bytes, &$size) 
    80   { 
    81     $ret = ''; 
    82     $size=0; 
    83     foreach ($bytes as $b) 
    84     { 
    85       if (isset(self::$_headerSafeMap[$b])) 
    86       { 
    87         $ret .= self::$_headerSafeMap[$b]; 
    88         ++$size; 
    89       } 
    90       else 
    91       { 
    92         $ret .= self::$_qpMap[$b]; 
    93         $size+=3; 
    94       } 
    95     } 
    96     return $ret; 
    97   } 
    98  
    9970} 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mime/HeaderFactory.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/CharsetObserver.php'; 
    1211 
    1312/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mime/HeaderSet.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/CharsetObserver.php'; 
    1211 
    1312/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mime/Headers/AbstractHeader.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/Header.php'; 
    12 //@require 'Swift/Mime/HeaderEncoder.php'; 
    13 //@require 'Swift/RfcComplianceException.php'; 
    14  
    1511/** 
    1612 * An abstract base MIME Header. 
     
    2319   
    2420  /** 
    25    * Special characters used in the syntax which need to be escaped. 
    26    * @var string[] 
    27    * @access private 
    28    */ 
    29   private $_specials = array(); 
    30    
    31   /** 
    32    * Tokens defined in RFC 2822 (and some related RFCs). 
    33    * @var string[] 
    34    * @access private 
    35    */ 
    36   private $_grammar = array(); 
    37    
    38   /** 
    3921   * The name of this Header. 
    4022   * @var string 
     
    4426   
    4527  /** 
     28   * The Grammar used for this Header. 
     29   * @var Swift_Mime_Grammar 
     30   * @access private 
     31   */ 
     32  private $_grammar; 
     33   
     34  /** 
    4635   * The Encoder used to encode this Header. 
    4736   * @var Swift_Encoder 
     
    7665   */ 
    7766  private $_cachedValue = null; 
     67   
     68  /** 
     69   * Creates a new Header. 
     70   * @param Swift_Mime_Grammar $grammar 
     71   */  
     72  public function __construct(Swift_Mime_Grammar $grammar) 
     73  { 
     74    $this->setGrammar($grammar); 
     75  } 
    7876   
    7977  /** 
     
    141139   
    142140  /** 
     141   * Set the grammar used for the header. 
     142   * @param Swift_Mime_Grammar $grammar 
     143   */ 
     144  public function setGrammar(Swift_Mime_Grammar $grammar) 
     145  { 
     146    $this->_grammar = $grammar; 
     147    $this->setCachedValue(null); 
     148  } 
     149   
     150  /** 
     151   * Get the grammar used for this Header. 
     152   * @return Swift_Mime_Grammar 
     153   */ 
     154  public function getGrammar() 
     155  { 
     156    return $this->_grammar; 
     157  } 
     158   
     159  /** 
    143160   * Get the name of this header (e.g. charset). 
    144161   * @return string 
     
    200217  { 
    201218    $this->_name = $name; 
    202   } 
    203    
    204   /** 
    205    * Initialize some RFC 2822 (and friends) ABNF grammar definitions. 
    206    * @access protected 
    207    */ 
    208   protected function initializeGrammar() 
    209   { 
    210     $this->_specials = array( 
    211       '(', ')', '<', '>', '[', ']', 
    212       ':', ';', '@', ',', '.', '"' 
    213       ); 
    214      
    215     /*** Refer to RFC 2822 for ABNF grammar ***/ 
    216      
    217     //All basic building blocks 
    218     $this->_grammar['NO-WS-CTL'] = '[\x01-\x08\x0B\x0C\x0E-\x19\x7F]'; 
    219     $this->_grammar['WSP'] = '[ \t]'; 
    220     $this->_grammar['CRLF'] = '(?:\r\n)'; 
    221     $this->_grammar['FWS'] = '(?:(?:' . $this->_grammar['WSP'] . '*' . 
    222         $this->_grammar['CRLF'] . ')?' . $this->_grammar['WSP'] . ')'; 
    223     $this->_grammar['text'] = '[\x00-\x08\x0B\x0C\x0E-\x7F]'; 
    224     $this->_grammar['quoted-pair'] = '(?:\\\\' . $this->_grammar['text'] . ')'; 
    225     $this->_grammar['ctext'] = '(?:' . $this->_grammar['NO-WS-CTL'] . 
    226         '|[\x21-\x27\x2A-\x5B\x5D-\x7E])'; 
    227     //Uses recursive PCRE (?1) -- could be a weak point?? 
    228     $this->_grammar['ccontent'] = '(?:' . $this->_grammar['ctext'] . '|' . 
    229         $this->_grammar['quoted-pair'] . '|(?1))'; 
    230     $this->_grammar['comment'] = '(\((?:' . $this->_grammar['FWS'] . '|' . 
    231         $this->_grammar['ccontent']. ')*' . $this->_grammar['FWS'] . '?\))'; 
    232     $this->_grammar['CFWS'] = '(?:(?:' . $this->_grammar['FWS'] . '?' . 
    233         $this->_grammar['comment'] . ')*(?:(?:' . $this->_grammar['FWS'] . '?' . 
    234         $this->_grammar['comment'] . ')|' . $this->_grammar['FWS'] . '))'; 
    235     $this->_grammar['qtext'] = '(?:' . $this->_grammar['NO-WS-CTL'] . 
    236         '|[\x21\x23-\x5B\x5D-\x7E])'; 
    237     $this->_grammar['qcontent'] = '(?:' . $this->_grammar['qtext'] . '|' . 
    238         $this->_grammar['quoted-pair'] . ')'; 
    239     $this->_grammar['quoted-string'] = '(?:' . $this->_grammar['CFWS'] . '?"' . 
    240         '(' . $this->_grammar['FWS'] . '?' . $this->_grammar['qcontent'] . ')*' . 
    241         $this->_grammar['FWS'] . '?"' . $this->_grammar['CFWS'] . '?)'; 
    242     $this->_grammar['atext'] = '[a-zA-Z0-9!#\$%&\'\*\+\-\/=\?\^_`\{\}\|~]'; 
    243     $this->_grammar['atom'] = '(?:' . $this->_grammar['CFWS'] . '?' . 
    244         $this->_grammar['atext'] . '+' . $this->_grammar['CFWS'] . '?)'; 
    245     $this->_grammar['dot-atom-text'] = '(?:' . $this->_grammar['atext'] . '+' . 
    246         '(\.' . $this->_grammar['atext'] . '+)*)'; 
    247     $this->_grammar['dot-atom'] = '(?:' . $this->_grammar['CFWS'] . '?' . 
    248         $this->_grammar['dot-atom-text'] . '+' . $this->_grammar['CFWS'] . '?)'; 
    249     $this->_grammar['word'] = '(?:' . $this->_grammar['atom'] . '|' . 
    250         $this->_grammar['quoted-string'] . ')'; 
    251     $this->_grammar['phrase'] = '(?:' . $this->_grammar['word'] . '+?)'; 
    252     $this->_grammar['no-fold-quote'] = '(?:"(?:' . $this->_grammar['qtext'] . 
    253         '|' . $this->_grammar['quoted-pair'] . ')*")'; 
    254     $this->_grammar['dtext'] = '(?:' . $this->_grammar['NO-WS-CTL'] . 
    255         '|[\x21-\x5A\x5E-\x7E])'; 
    256     $this->_grammar['no-fold-literal'] = '(?:\[(?:' . $this->_grammar['dtext'] . 
    257         '|' . $this->_grammar['quoted-pair'] . ')*\])'; 
    258      
    259     //Message IDs 
    260     $this->_grammar['id-left'] = '(?:' . $this->_grammar['dot-atom-text'] . '|' . 
    261         $this->_grammar['no-fold-quote'] . ')'; 
    262     $this->_grammar['id-right'] = '(?:' . $this->_grammar['dot-atom-text'] . '|' . 
    263         $this->_grammar['no-fold-literal'] . ')'; 
    264      
    265     //Addresses, mailboxes and paths 
    266     $this->_grammar['local-part'] = '(?:' . $this->_grammar['dot-atom'] . '|' . 
    267         $this->_grammar['quoted-string'] . ')'; 
    268     $this->_grammar['dcontent'] = '(?:' . $this->_grammar['dtext'] . '|' . 
    269         $this->_grammar['quoted-pair'] . ')'; 
    270     $this->_grammar['domain-literal'] = '(?:' . $this->_grammar['CFWS'] . '?\[(' . 
    271         $this->_grammar['FWS'] . '?' . $this->_grammar['dcontent'] . ')*?' . 
    272         $this->_grammar['FWS'] . '?\]' . $this->_grammar['CFWS'] . '?)'; 
    273     $this->_grammar['domain'] = '(?:' . $this->_grammar['dot-atom'] . '|' . 
    274         $this->_grammar['domain-literal'] . ')'; 
    275     $this->_grammar['addr-spec'] = '(?:' . $this->_grammar['local-part'] . '@' . 
    276         $this->_grammar['domain'] . ')'; 
    277   } 
    278    
    279   /** 
    280    * Get the grammar defined for $name token. 
    281    * @param string $name execatly as written in the RFC 
    282    * @return string 
    283    */ 
    284   protected function getGrammar($name) 
    285   { 
    286     if (array_key_exists($name, $this->_grammar)) 
    287     { 
    288       return $this->_grammar[$name]; 
    289     } 
    290     else 
    291     { 
    292       throw new Swift_RfcComplianceException( 
    293         "No such grammar '" . $name . "' defined." 
    294         ); 
    295     } 
    296   } 
    297    
    298   /** 
    299    * Escape special characters in a string (convert to quoted-pairs). 
    300    * @param string $token 
    301    * @param string[] $include additonal chars to escape 
    302    * @param string[] $exclude chars from escaping 
    303    * @return string 
    304    */ 
    305   protected function escapeSpecials($token, $include = array(), 
    306     $exclude = array()) 
    307   { 
    308     foreach ( 
    309       array_merge(array('\\'), array_diff($this->_specials, $exclude), $include) as $char) 
    310     { 
    311       $token = str_replace($char, '\\' . $char, $token); 
    312     } 
    313     return $token; 
    314219  } 
    315220   
     
    329234    $phraseStr = $string; 
    330235    //If it's not valid 
    331     if (!preg_match('/^' . $this->_grammar['phrase'] . '$/D', $phraseStr)) 
     236    if (!preg_match('/^' . $this->getGrammar()->getDefinition('phrase') . '$/D', $phraseStr)) 
    332237    { 
    333238      // .. but it is just ascii text, try escaping some characters 
    334239      // and make it a quoted-string 
    335       if (preg_match('/^' . $this->_grammar['text'] . '*$/D', $phraseStr)) 
    336       { 
    337         $phraseStr = $this->escapeSpecials( 
    338           $phraseStr, array('"'), $this->_specials 
     240      if (preg_match('/^' . $this->getGrammar()->getDefinition('text') . '*$/D', $phraseStr)) 
     241      { 
     242        $phraseStr = $this->getGrammar()->escapeSpecials( 
     243          $phraseStr, array('"'), $this->getGrammar()->getSpecials() 
    339244          ); 
    340245        $phraseStr = '"' . $phraseStr . '"'; 
     
    473378    $encodedTextLines = explode("\r\n", 
    474379      $this->_encoder->encodeString( 
    475         $token, $firstLineOffset, 75 - $encodingWrapperLength 
     380        $token, $firstLineOffset, 75 - $encodingWrapperLength, $this->_charset 
    476381        ) 
    477       ); 
    478      
    479     foreach ($encodedTextLines as $lineNum => $line) 
    480     { 
    481       $encodedTextLines[$lineNum] = '=?' . $charsetDecl . 
    482         '?' . $this->_encoder->getName() . 
    483         '?' . $line . '?='; 
     382    ); 
     383 
     384    if (strtolower($this->_charset) !== 'iso-2022-jp') // special encoding for iso-2022-jp using mb_encode_mimeheader 
     385    { 
     386      foreach ($encodedTextLines as $lineNum => $line) 
     387      { 
     388        $encodedTextLines[$lineNum] = '=?' . $charsetDecl . 
     389          '?' . $this->_encoder->getName() . 
     390          '?' . $line . '?='; 
     391      } 
    484392    } 
    485393     
     
    535443  /** 
    536444   * Generate a list of all tokens in the final header. 
    537    * @param string $string input, optional 
    538    * @return string[] 
    539    * @access private 
     445   * @param string $string The string to tokenize 
     446   * @return array An array of tokens as strings 
     447   * @access protected 
    540448   */ 
    541449  protected function toTokens($string = null) 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mime/Headers/DateHeader.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/Headers/AbstractHeader.php'; 
    1211 
    1312 
     
    3736   * </code> 
    3837   * @param string $name of Header 
     38   * @param Swift_Mime_Grammar $grammar 
    3939   */ 
    40   public function __construct($name
     40  public function __construct($name, Swift_Mime_Grammar $grammar
    4141  { 
    4242    $this->setFieldName($name); 
     43    parent::__construct($grammar); 
    4344  } 
    4445   
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mime/Headers/IdentificationHeader.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/Headers/AbstractHeader.php'; 
    12 //@require 'Swift/RfcComplianceException.php'; 
    1311 
    1412/** 
     
    3331   * Creates a new IdentificationHeader with the given $name and $id. 
    3432   * @param string $name 
     33   * @param Swift_Mime_Grammar $grammar 
    3534   */ 
    36   public function __construct($name
     35  public function __construct($name, Swift_Mime_Grammar $grammar
    3736  { 
    3837    $this->setFieldName($name); 
    39     $this->initializeGrammar(); 
     38    parent::__construct($grammar); 
    4039  } 
    4140   
     
    7473  /** 
    7574   * Set the ID used in the value of this header. 
    76    * @param string $id 
     75   * @param string|array $id 
    7776   * @throws Swift_RfcComplianceException 
    7877   */ 
    7978  public function setId($id) 
    8079  { 
    81     return $this->setIds(array($id)); 
     80    $this->setIds(is_array($id) ? $id : array($id)); 
    8281  } 
    8382   
     
    104103    $actualIds = array(); 
    105104     
    106     foreach ($ids as $k => $id) 
     105    foreach ($ids as $id) 
    107106    { 
    108       if (preg_match( 
    109         '/^' . $this->getGrammar('id-left') . '@' . 
    110         $this->getGrammar('id-right') . '$/D', 
    111         $id 
    112         )) 
    113       { 
    114         $actualIds[] = $id; 
    115       } 
    116       else 
    117       { 
    118         throw new Swift_RfcComplianceException( 
    119           'Invalid ID given <' . $id . '>' 
    120           ); 
    121       } 
     107      $this->_assertValidId($id); 
     108      $actualIds[] = $id; 
    122109    } 
    123110     
     
    159146  } 
    160147   
     148  /** 
     149   * Throws an Exception if the id passed does not comply with RFC 2822. 
     150   * @param string $id 
     151   * @throws Swift_RfcComplianceException 
     152   */ 
     153  private function _assertValidId($id) 
     154  { 
     155    if (!preg_match( 
     156      '/^' . $this->getGrammar()->getDefinition('id-left') . '@' . 
     157      $this->getGrammar()->getDefinition('id-right') . '$/D', 
     158      $id 
     159      )) 
     160    { 
     161      throw new Swift_RfcComplianceException( 
     162        'Invalid ID given <' . $id . '>' 
     163        ); 
     164    } 
     165  } 
    161166} 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mime/Headers/MailboxHeader.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/Headers/AbstractHeader.php'; 
    12 //@require 'Swift/Mime/HeaderEncoder.php'; 
    1311 
    1412/** 
     
    3230   * @param string $name of Header 
    3331   * @param Swift_Mime_HeaderEncoder $encoder 
    34    */ 
    35   public function __construct($name, Swift_Mime_HeaderEncoder $encoder) 
     32   * @param Swift_Mime_Grammar $grammar 
     33   */ 
     34  public function __construct($name, Swift_Mime_HeaderEncoder $encoder, Swift_Mime_Grammar $grammar) 
    3635  { 
    3736    $this->setFieldName($name); 
    3837    $this->setEncoder($encoder); 
    39     $this->initializeGrammar(); 
     38    parent::__construct($grammar); 
    4039  } 
    4140   
     
    169168  public function setAddresses($addresses) 
    170169  { 
    171     return $this->setNameAddresses(array_values((array) $addresses)); 
     170    $this->setNameAddresses(array_values((array) $addresses)); 
    172171  } 
    173172   
     
    269268    return implode(', ', $this->_createNameAddressStrings($mailboxes)); 
    270269  } 
     270 
     271  /** 
     272   * Redefine the encoding requirements for mailboxes. Commas and semicolons are used to separate  
     273   * multiple addresses, and should therefore be encoded 
     274   * @param string $token 
     275   * @return boolean 
     276   */ 
     277  protected function tokenNeedsEncoding($token) 
     278  { 
     279    return preg_match('/[,;]/', $token) || parent::tokenNeedsEncoding($token); 
     280  } 
    271281   
    272282  // -- Private methods 
     
    299309   * Throws an Exception if the address passed does not comply with RFC 2822. 
    300310   * @param string $address 
    301    * @throws Exception If invalid. 
    302    * @access protected 
     311   * @throws Swift_RfcComplianceException If invalid. 
     312   * @access private 
    303313   */ 
    304314  private function _assertValidAddress($address) 
    305315  { 
    306     if (!preg_match('/^' . $this->getGrammar('addr-spec') . '$/D', 
     316    if (!preg_match('/^' . $this->getGrammar()->getDefinition('addr-spec') . '$/D', 
    307317      $address)) 
    308318    { 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mime/Headers/ParameterizedHeader.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/Headers/UnstructuredHeader.php'; 
    12 //@require 'Swift/Mime/HeaderEncoder.php'; 
    13 //@require 'Swift/Mime/ParameterizedHeader.php'; 
    14 //@require 'Swift/Encoder.php'; 
    1511 
    1612/** 
     
    2622   
    2723  /** 
     24   * RFC 2231's definition of a token. 
     25   * @var string 
     26   */ 
     27  const TOKEN_REGEX = '(?:[\x21\x23-\x27\x2A\x2B\x2D\x2E\x30-\x39\x41-\x5A\x5E-\x7E]+)'; 
     28 
     29  /** 
    2830   * The Encoder used to encode the parameters. 
    2931   * @var Swift_Encoder 
     
    3840   */ 
    3941  private $_params = array(); 
    40    
    41   /** 
    42    * RFC 2231's definition of a token. 
    43    * @var string 
    44    * @access private 
    45    */ 
    46   private $_tokenRe; 
    4742   
    4843  /** 
     
    5146   * @param Swift_Mime_HeaderEncoder $encoder 
    5247   * @param Swift_Encoder $paramEncoder, optional 
     48   * @param Swift_Mime_Grammar $grammar 
    5349   */  
    5450  public function __construct($name, Swift_Mime_HeaderEncoder $encoder, 
    55     Swift_Encoder $paramEncoder = null) 
    56   { 
    57     $this->setFieldName($name); 
    58     $this->setEncoder($encoder); 
     51    Swift_Encoder $paramEncoder = null, Swift_Mime_Grammar $grammar) 
     52  { 
     53    parent::__construct($name, $encoder, $grammar); 
    5954    $this->_paramEncoder = $paramEncoder; 
    60     $this->initializeGrammar(); 
    61     $this->_tokenRe = '(?:[\x21\x23-\x27\x2A\x2B\x2D\x2E\x30-\x39\x41-\x5A\x5E-\x7E]+)'; 
    6255  } 
    6356   
     
    151144   * This doesn't need to be overridden in theory, but it is for implementation 
    152145   * reasons to prevent potential breakage of attributes. 
    153    * @return string[] 
     146   * @param string $string The string to tokenize 
     147   * @return array An array of tokens as strings 
    154148   * @access protected 
    155149   */ 
     
    193187     
    194188    //If it's not already a valid parameter value... 
    195     if (!preg_match('/^' . $this->_tokenRe . '$/D', $value)) 
     189    if (!preg_match('/^' . self::TOKEN_REGEX . '$/D', $value)) 
    196190    { 
    197191      //TODO: text, or something else?? 
    198192      //... and it's not ascii 
    199       if (!preg_match('/^' . $this->getGrammar('text') . '*$/D', $value)) 
     193      if (!preg_match('/^' . $this->getGrammar()->getDefinition('text') . '*$/D', $value)) 
    200194      { 
    201195        $encoded = true; 
     
    214208      { 
    215209        $value = $this->_paramEncoder->encodeString( 
    216           $origValue, $firstLineOffset, $maxValueLength 
     210          $origValue, $firstLineOffset, $maxValueLength, $this->getCharset() 
    217211          ); 
    218212      } 
     
    233227      { 
    234228        $paramLines[] = $name . '*' . $i . 
    235           $this->_getEndOfParameterValue($line, $encoded, $i == 0); 
     229          $this->_getEndOfParameterValue($line, true, $i == 0); 
    236230      } 
    237231      return implode(";\r\n ", $paramLines); 
     
    255249  private function _getEndOfParameterValue($value, $encoded = false, $firstLine = false) 
    256250  { 
    257     if (!preg_match('/^' . $this->_tokenRe . '$/D', $value)) 
     251    if (!preg_match('/^' . self::TOKEN_REGEX . '$/D', $value)) 
    258252    { 
    259253      $value = '"' . $value . '"'; 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mime/Headers/PathHeader.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/Headers/AbstractHeader.php'; 
    12 //@require 'Swift/RfcComplianceException.php'; 
    1311 
    1412/** 
     
    3129   * Creates a new PathHeader with the given $name. 
    3230   * @param string $name 
     31   * @param Swift_Mime_Grammar $grammar 
    3332   */ 
    34   public function __construct($name
     33  public function __construct($name, Swift_Mime_Grammar $grammar
    3534  { 
    3635    $this->setFieldName($name); 
    37     $this->initializeGrammar(); 
     36    parent::__construct($grammar); 
    3837  } 
    3938   
     
    8180      $this->_address = null; 
    8281    } 
    83     elseif ('' == $address 
    84       || preg_match('/^' . $this->getGrammar('addr-spec') . '$/D', $address)) 
     82    elseif ('' == $address) 
    8583    { 
    86       $this->_address = $address
     84      $this->_address = ''
    8785    } 
    8886    else 
    8987    { 
    90       throw new Swift_RfcComplianceException( 
    91         'Address set in PathHeader does not comply with addr-spec of RFC 2822.' 
    92         ); 
     88      $this->_assertValidAddress($address); 
     89      $this->_address = $address; 
    9390    } 
    9491    $this->setCachedValue(null); 
     
    124121  } 
    125122   
     123  /** 
     124   * Throws an Exception if the address passed does not comply with RFC 2822. 
     125   * @param string $address 
     126   * @throws Swift_RfcComplianceException If invalid. 
     127   * @access private 
     128   */ 
     129  private function _assertValidAddress($address) 
     130  { 
     131    if (!preg_match('/^' . $this->getGrammar()->getDefinition('addr-spec') . '$/D', 
     132      $address)) 
     133    { 
     134      throw new Swift_RfcComplianceException( 
     135        'Address set in PathHeader does not comply with addr-spec of RFC 2822.' 
     136        ); 
     137    } 
     138  } 
     139   
    126140} 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mime/Headers/UnstructuredHeader.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/Headers/AbstractHeader.php'; 
    12 //@require 'Swift/Mime/HeaderEncoder.php'; 
    1311 
    1412/** 
     
    3331   * @param string $name 
    3432   * @param Swift_Mime_HeaderEncoder $encoder 
     33   * @param Swift_Mime_Grammar $grammar 
    3534   */ 
    36   public function __construct($name, Swift_Mime_HeaderEncoder $encoder
     35  public function __construct($name, Swift_Mime_HeaderEncoder $encoder, Swift_Mime_Grammar $grammar
    3736  { 
    3837    $this->setFieldName($name); 
    3938    $this->setEncoder($encoder); 
     39    parent::__construct($grammar); 
    4040  } 
     41   
    4142  /** 
    4243   * Get the type of Header that this instance represents. 
     
    9899    { 
    99100      $this->setCachedValue( 
    100         str_replace('\\', '\\\\', $this->encodeWords( 
    101           $this, $this->_value, -1, $this->getCharset(), $this->getEncoder() 
    102           )) 
     101        $this->encodeWords($this, $this->_value) 
    103102        ); 
    104103    } 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mime/Message.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/MimeEntity.php'; 
    1211 
    1312/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mime/MimeEntity.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/InputByteStream.php'; 
    12 //@require 'Swift/Mime/EncodingObserver.php'; 
    13 //@require 'Swift/Mime/CharsetObserver.php'; 
    1411 
    1512/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mime/MimePart.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/SimpleMimeEntity.php'; 
    12 //@require 'Swift/Mime/ContentEncoder.php'; 
    13 //@require 'Swift/Mime/HeaderSet.php'; 
    14 //@require 'Swift/KeyCache.php'; 
    1511 
    1612/** 
     
    4238   * @param Swift_Mime_ContentEncoder $encoder 
    4339   * @param Swift_KeyCache $cache 
     40   * @param Swift_Mime_Grammar $grammar 
    4441   * @param string $charset 
    4542   */ 
    4643  public function __construct(Swift_Mime_HeaderSet $headers, 
    47     Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, $charset = null) 
    48   { 
    49     parent::__construct($headers, $encoder, $cache); 
     44    Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_Mime_Grammar $grammar, $charset = null) 
     45  { 
     46    parent::__construct($headers, $encoder, $cache, $grammar); 
    5047    $this->setContentType('text/plain'); 
    5148    if (!is_null($charset)) 
     
    6259   * @param string $contentType optional 
    6360   * @param string $charset optional 
     61   * @param Swift_Mime_MimePart 
    6462   */ 
    6563  public function setBody($body, $contentType = null, $charset = null) 
    6664  { 
     65    if (isset($charset)) 
     66    { 
     67      $this->setCharset($charset); 
     68    } 
     69    $body = $this->_convertString($body); 
     70 
    6771    parent::setBody($body, $contentType); 
    68     if (isset($charset)) 
    69     { 
    70       $this->setCharset($charset); 
    71     } 
     72 
    7273    return $this; 
    7374  } 
     
    8788   *  
    8889   * @param string $charset 
     90   * @param Swift_Mime_MimePart 
    8991   */ 
    9092  public function setCharset($charset) 
     
    114116   *  
    115117   * @param string $format 
     118   * @param Swift_Mime_MimePart 
    116119   */ 
    117120  public function setFormat($format) 
     
    138141   *  
    139142   * @param boolean $delsp 
     143   * @param Swift_Mime_MimePart 
    140144   */ 
    141145  public function setDelSp($delsp = true) 
     
    194198  } 
    195199   
     200  /** Encode charset when charset is not utf-8 */ 
     201  protected function _convertString($string) 
     202  { 
     203    $charset = strtolower($this->getCharset()); 
     204    if (!in_array($charset, array('utf-8', 'iso-8859-1', ""))) 
     205    { 
     206      // mb_convert_encoding must be the first one to check, since iconv cannot convert some words. 
     207      if (function_exists('mb_convert_encoding')) 
     208      { 
     209        $string = mb_convert_encoding($string, $charset, 'utf-8'); 
     210      } 
     211      else if (function_exists('iconv')) 
     212      { 
     213        $string = iconv($charset, 'utf-8//TRANSLIT//IGNORE', $string); 
     214      } 
     215      else 
     216      { 
     217          throw new Swift_SwiftException('No suitable convert encoding function (use UTF-8 as your harset or install the mbstring or iconv extension).'); 
     218      } 
     219      return $string; 
     220    } 
     221    return $string; 
     222  } 
     223 
    196224} 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mime/ParameterizedHeader.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/Header.php'; 
    1211 
    1312/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mime/SimpleHeaderFactory.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/HeaderFactory.php'; 
    12 //@require 'Swift/Mime/HeaderEncoder.php'; 
    13 //@require 'Swift/Encoder.php'; 
    14 //@require 'Swift/Mime/Headers/MailboxHeader.php'; 
    15 //@require 'Swift/Mime/Headers/DateHeader.php'; 
    16 //@require 'Swift/Mime/Headers/UnstructuredHeader.php'; 
    17 //@require 'Swift/Mime/Headers/ParameterizedHeader.php'; 
    18 //@require 'Swift/Mime/Headers/IdentificationHeader.php'; 
    19 //@require 'Swift/Mime/Headers/PathHeader.php'; 
    2011 
    2112/** 
     
    3425  private $_paramEncoder; 
    3526   
     27  /** The Grammar */ 
     28  private $_grammar; 
     29   
    3630  /** The charset of created Headers */ 
    3731  private $_charset; 
     
    4135   * @param Swift_Mime_HeaderEncoder $encoder 
    4236   * @param Swift_Encoder $paramEncoder 
     37   * @param Swift_Mime_Grammar $grammar 
    4338   * @param string $charset 
    4439   */ 
    4540  public function __construct(Swift_Mime_HeaderEncoder $encoder, 
    46     Swift_Encoder $paramEncoder, $charset = null) 
     41    Swift_Encoder $paramEncoder, Swift_Mime_Grammar $grammar, $charset = null) 
    4742  { 
    4843    $this->_encoder = $encoder; 
    4944    $this->_paramEncoder = $paramEncoder; 
     45    $this->_grammar = $grammar; 
    5046    $this->_charset = $charset; 
    5147  } 
     
    5955  public function createMailboxHeader($name, $addresses = null) 
    6056  { 
    61     $header = new Swift_Mime_Headers_MailboxHeader($name, $this->_encoder); 
     57    $header = new Swift_Mime_Headers_MailboxHeader($name, $this->_encoder, $this->_grammar); 
    6258    if (isset($addresses)) 
    6359    { 
     
    7672  public function createDateHeader($name, $timestamp = null) 
    7773  { 
    78     $header = new Swift_Mime_Headers_DateHeader($name); 
     74    $header = new Swift_Mime_Headers_DateHeader($name, $this->_grammar); 
    7975    if (isset($timestamp)) 
    8076    { 
     
    9389  public function createTextHeader($name, $value = null) 
    9490  { 
    95     $header = new Swift_Mime_Headers_UnstructuredHeader($name, $this->_encoder); 
     91    $header = new Swift_Mime_Headers_UnstructuredHeader($name, $this->_encoder, $this->_grammar); 
    9692    if (isset($value)) 
    9793    { 
     
    115111      $this->_encoder, (strtolower($name) == 'content-disposition') 
    116112        ? $this->_paramEncoder 
    117         : null 
     113        : null, 
     114        $this->_grammar 
    118115      ); 
    119116    if (isset($value)) 
     
    137134  public function createIdHeader($name, $ids = null) 
    138135  { 
    139     $header = new Swift_Mime_Headers_IdentificationHeader($name); 
     136    $header = new Swift_Mime_Headers_IdentificationHeader($name, $this->_grammar); 
    140137    if (isset($ids)) 
    141138    { 
     
    154151  public function createPathHeader($name, $path = null) 
    155152  { 
    156     $header = new Swift_Mime_Headers_PathHeader($name); 
     153    $header = new Swift_Mime_Headers_PathHeader($name, $this->_grammar); 
    157154    if (isset($path)) 
    158155    { 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mime/SimpleHeaderSet.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/HeaderSet.php'; 
    12 //@require 'Swift/Mime/HeaderFactory.php'; 
    1311 
    1412/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mime/SimpleMessage.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/Message.php'; 
    12 //@require 'Swift/Mime/MimePart.php'; 
    13 //@require 'Swift/Mime/MimeEntity.php'; 
    14 //@require 'Swift/Mime/HeaderSet.php'; 
    15 //@require 'Swift/Mime/ContentEncoder.php'; 
    1611 
    1712/** 
     
    3025   * @param Swift_Mime_ContentEncoder $encoder 
    3126   * @param Swift_KeyCache $cache 
     27   * @param Swift_Mime_Grammar $grammar 
    3228   * @param string $charset 
    3329   */ 
    3430  public function __construct(Swift_Mime_HeaderSet $headers, 
    35     Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, $charset = null) 
    36   { 
    37     parent::__construct($headers, $encoder, $cache, $charset); 
     31    Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_Mime_Grammar $grammar, $charset = null) 
     32  { 
     33    parent::__construct($headers, $encoder, $cache, $grammar, $charset); 
    3834    $this->getHeaders()->defineOrdering(array( 
    3935      'Return-Path', 
     
    7268   * Set the subject of this message. 
    7369   * @param string $subject 
     70   * @return Swift_Mime_SimpleMessage 
    7471   */ 
    7572  public function setSubject($subject) 
     
    9491   * Set the date at which this message was created. 
    9592   * @param int $date 
     93   * @return Swift_Mime_SimpleMessage 
    9694   */ 
    9795  public function setDate($date) 
     
    116114   * Set the return-path (the bounce address) of this message. 
    117115   * @param string $address 
     116   * @return Swift_Mime_SimpleMessage 
    118117   */ 
    119118  public function setReturnPath($address) 
     
    140139   * @param string $sender 
    141140   * @param string $name optional 
     141   * @return Swift_Mime_SimpleMessage 
    142142   */ 
    143143  public function setSender($address, $name = null) 
     
    189189   * @param string $addresses 
    190190   * @param string $name optional 
     191   * @return Swift_Mime_SimpleMessage 
    191192   */ 
    192193  public function setFrom($addresses, $name = null) 
     
    221222   * @param string $address 
    222223   * @param string $name optional 
     224   * @return Swift_Mime_SimpleMessage 
    223225   */ 
    224226  public function addReplyTo($address, $name = null) 
     
    239241   * @param string $addresses 
    240242   * @param string $name optional 
     243   * @return Swift_Mime_SimpleMessage 
    241244   */ 
    242245  public function setReplyTo($addresses, $name = null) 
     
    271274   * @param string $address 
    272275   * @param string $name optional 
     276   * @return Swift_Mime_SimpleMessage 
    273277   */ 
    274278  public function addTo($address, $name = null) 
     
    289293   * @param array $addresses 
    290294   * @param string $name optional 
     295   * @return Swift_Mime_SimpleMessage 
    291296   */ 
    292297  public function setTo($addresses, $name = null) 
     
    321326   * @param string $address 
    322327   * @param string $name optional 
     328   * @return Swift_Mime_SimpleMessage 
    323329   */ 
    324330  public function addCc($address, $name = null) 
     
    337343   * @param array $addresses 
    338344   * @param string $name optional 
     345   * @return Swift_Mime_SimpleMessage 
    339346   */ 
    340347  public function setCc($addresses, $name = null) 
     
    369376   * @param string $address 
    370377   * @param string $name optional 
     378   * @return Swift_Mime_SimpleMessage 
    371379   */ 
    372380  public function addBcc($address, $name = null) 
     
    385393   * @param array $addresses 
    386394   * @param string $name optional 
     395   * @return Swift_Mime_SimpleMessage 
    387396   */ 
    388397  public function setBcc($addresses, $name = null) 
     
    414423   * The value is an integer where 1 is the highest priority and 5 is the lowest. 
    415424   * @param int $priority 
     425   * @return Swift_Mime_SimpleMessage 
    416426   */ 
    417427  public function setPriority($priority) 
     
    459469   * Ask for a delivery receipt from the recipient to be sent to $addresses 
    460470   * @param array $addresses 
     471   * @return Swift_Mime_SimpleMessage 
    461472   */ 
    462473  public function setReadReceiptTo($addresses) 
     
    482493   * Attach a {@link Swift_Mime_MimeEntity} such as an Attachment or MimePart. 
    483494   * @param Swift_Mime_MimeEntity $entity 
     495   * @return Swift_Mime_SimpleMessage 
    484496   */ 
    485497  public function attach(Swift_Mime_MimeEntity $entity) 
     
    492504   * Remove an already attached entity. 
    493505   * @param Swift_Mime_MimeEntity $entity 
     506   * @return Swift_Mime_SimpleMessage 
    494507   */ 
    495508  public function detach(Swift_Mime_MimeEntity $entity) 
     
    582595  { 
    583596    $part = new parent($this->getHeaders()->newInstance(), $this->getEncoder(), 
    584       $this->_getCache(), $this->_userCharset 
     597      $this->_getCache(), $this->_getGrammar(), $this->_userCharset 
    585598      ); 
    586599    $part->setContentType($this->_userContentType); 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Mime/SimpleMimeEntity.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/HeaderSet.php'; 
    12 //@require 'Swift/OutputByteStream.php'; 
    13 //@require 'Swift/Mime/ContentEncoder.php'; 
    14 //@require 'Swift/KeyCache.php'; 
    1511 
    1612/** 
     
    3127  /** The encoder that encodes the body into a streamable format */ 
    3228  private $_encoder; 
     29 
     30  /** The grammar to use for id validation */ 
     31  private $_grammar; 
    3332   
    3433  /** A mime bounary, if any is used */ 
     
    8079   * @param Swift_Mime_ContentEncoder $encoder 
    8180   * @param Swift_KeyCache $cache 
     81   * @param Swift_Mime_Grammar $grammar 
    8282   */ 
    8383  public function __construct(Swift_Mime_HeaderSet $headers, 
    84     Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache) 
     84    Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, 
     85    Swift_Mime_Grammar $grammar) 
    8586  { 
    8687    $this->_cacheKey = uniqid(); 
    8788    $this->_cache = $cache; 
    8889    $this->_headers = $headers; 
     90    $this->_grammar = $grammar; 
    8991    $this->setEncoder($encoder); 
    9092    $this->_headers->defineOrdering( 
     
    113115        ) 
    114116      ); 
    115     $this->generateId(); 
     117 
     118    $this->_id = $this->getRandomId(); 
    116119  } 
    117120   
     
    122125  public function generateId() 
    123126  { 
    124     $idLeft = time() . '.' . uniqid(); 
    125     $idRight = !empty($_SERVER['SERVER_NAME']) 
    126       ? $_SERVER['SERVER_NAME'] 
    127       : 'swift.generated'; 
    128     $this->_id = $idLeft . '@' . $idRight; 
    129     return $this->getId(); 
     127    $this->setId($this->getRandomId()); 
     128    return $this->_id; 
    130129  } 
    131130   
     
    161160   * Set the Content-type of this entity. 
    162161   * @param string $type 
     162   * @return Swift_Mime_SimpleMimeEntity 
    163163   */ 
    164164  public function setContentType($type) 
     
    186186   * Set the CID of this entity. 
    187187   * @param string $id 
     188   * @return Swift_Mime_SimpleMimeEntity 
    188189   */ 
    189190  public function setId($id) 
     
    211212   * This method sets a value in the Content-ID header. 
    212213   * @param string $description 
     214   * @return Swift_Mime_SimpleMimeEntity 
    213215   */ 
    214216  public function setDescription($description) 
     
    234236   * Though not enforced by the library, lines should not exceed 1000 chars. 
    235237   * @param int $length 
     238   * @return Swift_Mime_SimpleMimeEntity 
    236239   */ 
    237240  public function setMaxLineLength($length) 
     
    254257   * @param array $children Swiift_Mime_Entity instances 
    255258   * @param int $compoundLevel For internal use only 
     259   * @return Swift_Mime_SimpleMimeEntity 
    256260   */ 
    257261  public function setChildren(array $children, $compoundLevel = null) 
     
    347351   * @param mixed $body 
    348352   * @param string $contentType optional 
     353   * @return Swift_Mime_SimpleMimeEntity 
    349354   */ 
    350355  public function setBody($body, $contentType = null) 
     
    375380   * Set the encoder used for the body of this entity. 
    376381   * @param Swift_Mime_ContentEncoder $encoder 
     382   * @return Swift_Mime_SimpleMimeEntity 
    377383   */ 
    378384  public function setEncoder(Swift_Mime_ContentEncoder $encoder) 
     
    406412   * @param string $boundary 
    407413   * @throws Swift_RfcComplianceException 
     414   * @return Swift_Mime_SimpleMimeEntity 
    408415   */ 
    409416  public function setBoundary($boundary) 
     
    636643   
    637644  /** 
     645   * Get the grammar used for validation. 
     646   * @return Swift_Mime_Grammar 
     647   */ 
     648  protected function _getGrammar() 
     649  { 
     650    return $this->_grammar; 
     651  } 
     652   
     653  /** 
    638654   * Empty the KeyCache for this entity. 
    639655   */ 
     
    641657  { 
    642658    $this->_cache->clearKey($this->_cacheKey, 'body'); 
     659  } 
     660   
     661  /** 
     662   * Returns a random Content-ID or Message-ID. 
     663   * @return string 
     664   */ 
     665  protected function getRandomId() 
     666  { 
     667    $idLeft = time() . '.' . uniqid(); 
     668    $idRight = !empty($_SERVER['SERVER_NAME']) 
     669      ? $_SERVER['SERVER_NAME'] 
     670      : 'swift.generated'; 
     671    $id = $idLeft . '@' . $idRight; 
     672 
     673    try 
     674    { 
     675      $this->_assertValidId($id); 
     676    } 
     677    catch (Swift_RfcComplianceException $e) 
     678    { 
     679      $id = $idLeft . '@swift.generated'; 
     680    } 
     681 
     682    return $id; 
    643683  } 
    644684   
     
    669709      $boundary)) 
    670710    { 
    671       throw new Exception('Mime boundary set is not RFC 2046 compliant.'); 
     711      throw new Swift_RfcComplianceException('Mime boundary set is not RFC 2046 compliant.'); 
    672712    } 
    673713  } 
     
    724764  { 
    725765    return new self($this->_headers->newInstance(), 
    726       $this->_encoder, $this->_cache); 
     766      $this->_encoder, $this->_cache, $this->_grammar); 
    727767  } 
    728768   
     
    791831  } 
    792832   
     833  /** 
     834   * Throws an Exception if the id passed does not comply with RFC 2822. 
     835   * @param string $id 
     836   * @throws Swift_RfcComplianceException 
     837   */ 
     838  private function _assertValidId($id) 
     839  { 
     840    if (!preg_match( 
     841      '/^' . $this->_grammar->getDefinition('id-left') . '@' . 
     842      $this->_grammar->getDefinition('id-right') . '$/D', 
     843      $id 
     844      )) 
     845    { 
     846      throw new Swift_RfcComplianceException( 
     847        'Invalid ID given <' . $id . '>' 
     848        ); 
     849    } 
     850  } 
     851   
    793852} 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/MimePart.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/MimePart.php'; 
    12 //@require 'Swift/DependencyContainer.php'; 
    1311 
    1412/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Plugins/AntiFloodPlugin.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Events/SendListener.php'; 
    12 //@require 'Swift/Events/SendEvent.php'; 
    13 //@require 'Swift/Plugins/Sleeper.php'; 
    1411 
    1512/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Plugins/BandwidthMonitorPlugin.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Events/SendListener.php'; 
    12 //@require 'Swift/Events/SendEvent.php'; 
    13 //@require 'Swift/Events/CommandListener.php'; 
    14 //@require 'Swift/Events/CommandEvent.php'; 
    15 //@require 'Swift/Events/ResponseListener.php'; 
    16 //@require 'Swift/Events/ResponseEvent.php'; 
    17 //@require 'Swift/InputByteStream.php'; 
    1811 
    1912/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Plugins/DecoratorPlugin.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Events/SendListener.php'; 
    12 //@require 'Swift/Events/SendEvent.php'; 
    13 //@require 'Swift/Plugins/Decorator/Replacements.php'; 
    1411 
    1512/** 
     
    2017 *  
    2118 * @author Chris Corbyn 
     19 * @author Fabien Potencier 
    2220 */ 
    2321class Swift_Plugins_DecoratorPlugin 
     
    2927   
    3028  /** The body as it was before replacements */ 
    31   private $_orginalBody; 
    32  
    33   /** The original subject of the message, before replacements */ 
    34   private $_originalSubject
     29  private $_originalBody; 
     30 
     31  /** The original headers of the message, before replacements */ 
     32  private $_originalHeaders = array()
    3533 
    3634  /** Bodies of children before they are replaced */ 
     
    5856   * given to {@link Swift_Plugins_Decorator_Replacements::getReplacementsFor()}. 
    5957   *  
    60    * @param mixed $replacements 
     58   * @param mixed $replacements Array or Swift_Plugins_Decorator_Replacements 
    6159   */ 
    6260  public function __construct($replacements) 
    6361  { 
    64     if (!($replacements instanceof Swift_Plugins_Decorator_Replacements)) 
     62    $this->setReplacements($replacements); 
     63  } 
     64 
     65  /** 
     66   * Sets replacements. 
     67   * 
     68   * @param mixed $replacements Array or Swift_Plugins_Decorator_Replacements 
     69   * 
     70   * @see __construct() 
     71   */ 
     72  public function setReplacements($replacements) 
     73  { 
     74    if (!($replacements instanceof \Swift_Plugins_Decorator_Replacements)) 
    6575    { 
    6676      $this->_replacements = (array) $replacements; 
     
    96106        $message->setBody($bodyReplaced); 
    97107      } 
    98       $subject = $message->getSubject(); 
    99       $subjectReplaced = str_replace( 
    100         $search, $replace, $subject 
    101         ); 
    102       if ($subject != $subjectReplaced) 
    103       { 
    104         $this->_originalSubject = $subject; 
    105         $message->setSubject($subjectReplaced); 
    106       } 
     108 
     109      foreach ($message->getHeaders()->getAll() as $header) 
     110      { 
     111        $body = $header->getFieldBodyModel(); 
     112        $count = 0; 
     113        if (is_array($body)) 
     114        { 
     115          $bodyReplaced = array(); 
     116          foreach ($body as $key => $value) 
     117          { 
     118            $count1 = 0; 
     119            $count2 = 0; 
     120            $key = is_string($key) ? str_replace($search, $replace, $key, $count1) : $key; 
     121            $value = is_string($value) ? str_replace($search, $replace, $value, $count2) : $value; 
     122            $bodyReplaced[$key] = $value; 
     123 
     124            if (!$count && ($count1 || $count2)) 
     125            { 
     126              $count = 1; 
     127            } 
     128          } 
     129        } 
     130        else 
     131        { 
     132          $bodyReplaced = str_replace($search, $replace, $body, $count); 
     133        } 
     134 
     135        if ($count) 
     136        { 
     137          $this->_originalHeaders[$header->getFieldName()] = $body; 
     138          $header->setFieldBodyModel($bodyReplaced); 
     139        } 
     140      } 
     141 
    107142      $children = (array) $message->getChildren(); 
    108143      foreach ($children as $child) 
     
    177212        $this->_originalBody = null; 
    178213      } 
    179       if (isset($this->_originalSubject)) 
    180       { 
    181         $message->setSubject($this->_originalSubject); 
    182         $this->_originalSubject = null; 
     214      if (!empty($this->_originalHeaders)) 
     215      { 
     216        foreach ($message->getHeaders()->getAll() as $header) 
     217        { 
     218          if (array_key_exists($header->getFieldName(), $this->_originalHeaders)) 
     219          { 
     220            $header->setFieldBodyModel($this->_originalHeaders[$header->getFieldName()]); 
     221          } 
     222        } 
     223        $this->_originalHeaders = array(); 
    183224      } 
    184225      if (!empty($this->_originalChildBodies)) 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Plugins/LoggerPlugin.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Events/CommandListener.php'; 
    12 //@require 'Swift/Events/CommandEvent.php'; 
    13 //@require 'Swift/Events/ResponseListener.php'; 
    14 //@require 'Swift/Events/ResponseEvent.php'; 
    15 //@require 'Swift/Events/TransportChangeListener.php'; 
    16 //@require 'Swift/Events/TransportChangeEvent.php'; 
    17 //@require 'Swift/Events/TransportExceptionEvent.php'; 
    18 //@require 'Swift/Events/TransportExceptionListener.php'; 
    19 //@require 'Swift/Events/TransportException.php'; 
    20 //@require 'Swift/Plugins/Logger.php'; 
    2111 
    2212/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Plugins/Pop/Pop3Exception.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/IoException.php'; 
    1211 
    1312/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Plugins/PopBeforeSmtpPlugin.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Events/TransportChangeListener.php'; 
    12 //@require 'Swift/Events/TransportChangeEvent.php'; 
    1311 
    1412/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Plugins/Reporter.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/Message.php'; 
    1211 
    1312/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Plugins/ReporterPlugin.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Events/SendListener.php'; 
    12 //@require 'Swift/Events/SendEvent.php'; 
    13 //@require 'Swift/Plugins/Reporter.php'; 
    1411 
    1512/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Plugins/Reporters/HitReporter.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Plugins/Reporter.php'; 
    12 //@require 'Swift/Mime/Message.php'; 
    1311 
    1412/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Plugins/Reporters/HtmlReporter.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Plugins/Reporter.php'; 
    12 //@require 'Swift/Mime/Message.php'; 
    1311 
    1412/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Plugins/ThrottlerPlugin.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Events/SendEvent.php'; 
    12 //@require 'Swift/Plugins/BandwidthMonitorPlugin.php'; 
    13 //@require 'Swift/Plugins/Sleeper.php'; 
    14 //@require 'Swift/Plugins/Timer.php'; 
    1511 
    1612/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Preferences.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/DependencyContainer.php'; 
    1211 
    1312/** 
     
    7473  } 
    7574   
     75  /** 
     76   * Add the 
     77   * @param boolean $dotEscape 
     78   * @return Swift_Preferences 
     79   */ 
     80  public function setQPDotEscape($dotEscape) 
     81  { 
     82    $dotEscape=!empty($dotEscape); 
     83    Swift_DependencyContainer::getInstance() 
     84      -> register('mime.qpcontentencoder') 
     85      -> asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder') 
     86      -> withDependencies(array('mime.charstream', 'mime.bytecanonicalizer')) 
     87      -> addConstructorValue($dotEscape); 
     88    return $this; 
     89  } 
     90   
    7691} 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/RfcComplianceException.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/SwiftException.php'; 
    1211 
    1312/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/SendmailTransport.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Transport/SendmailTransport.php'; 
    12 //@require 'Swift/DependencyContainer.php'; 
    1311 
    1412/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/SmtpTransport.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Transport/EsmtpTransport.php'; 
    12 //@require 'Swift/DependencyContainer.php'; 
    1311 
    1412/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Spool.php

    r23762 r33569  
    3636   * Queues a message. 
    3737   * @param Swift_Mime_Message $message The message to store 
     38   * 
     39   * @return boolean Whether the operation has succeeded 
    3840   */ 
    3941  public function queueMessage(Swift_Mime_Message $message); 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/StreamFilter.php'; 
    1211 
    1312/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/StreamFilters/StringReplacementFilter.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/StreamFilter.php'; 
    1211 
    1312/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/StreamFilters/StringReplacementFilterFactory.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/StreamFilters/StringReplacementFilter.php'; 
    12 //@require 'Swift/StreamFilterFactory.php'; 
    1311 
    1412/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Transport.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Mime/Message.php'; 
    12 //@require 'Swift/Events/EventListener.php'; 
    1311 
    1412/** 
     
    4240   * Send the given Message. 
    4341   *  
    44    * Recipient/sender data will be retreived from the Message API. 
     42   * Recipient/sender data will be retrieved from the Message API. 
    4543   * The return value is the number of recipients who were accepted for delivery. 
    4644   *  
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Transport/AbstractSmtpTransport.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Transport.php'; 
    12 //@require 'Swift/Transport/IoBuffer.php'; 
    13 //@require 'Swift/Transport/CommandSentException.php'; 
    14 //@require 'Swift/TransportException.php'; 
    15 //@require 'Swift/Mime/Message.php'; 
    16 //@require 'Swift/Events/EventDispatcher.php'; 
    17 //@require 'Swift/Events/EventListener.php'; 
    1811 
    1912/** 
     
    4033  protected $_eventDispatcher; 
    4134   
     35  /** Source Ip */ 
     36  protected $_sourceIp; 
     37   
    4238  /** Return an array of params for the Buffer */ 
    4339  abstract protected function _getBufferParams(); 
     
    6460   *  
    6561   * @param string $domain 
     62   * @return Swift_Transport_AbstractSmtpTransport 
    6663   */ 
    6764  public function setLocalDomain($domain) 
     
    8178  } 
    8279   
     80 
     81  /** 
     82   * Sets the sourceIp 
     83   * @param string $source 
     84   */ 
     85  public function setSourceIp($source)  
     86  { 
     87    $this->_sourceIp=$source; 
     88  } 
     89 
     90  /** 
     91   * Returns the ip used to connect to the destination 
     92   * @return string 
     93   */ 
     94  public function getSourceIp() 
     95  { 
     96    return $this->_sourceIp; 
     97  } 
     98 
    8399  /** 
    84100   * Start the SMTP connection. 
     
    130146   * Send the given Message. 
    131147   *  
    132    * Recipient/sender data will be retreived from the Message API. 
     148   * Recipient/sender data will be retrieved from the Message API. 
    133149   * The return value is the number of recipients who were accepted for delivery. 
    134150   *  
     
    142158    $failedRecipients = (array) $failedRecipients; 
    143159     
     160    if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) 
     161    { 
     162      $this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); 
     163      if ($evt->bubbleCancelled()) 
     164      { 
     165        return 0; 
     166      } 
     167    } 
     168     
    144169    if (!$reversePath = $this->_getReversePath($message)) 
    145170    { 
     
    147172        'Cannot send message without a sender address' 
    148173        ); 
    149     } 
    150      
    151     if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) 
    152     { 
    153       $this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); 
    154       if ($evt->bubbleCancelled()) 
    155       { 
    156         return 0; 
    157       } 
    158174    } 
    159175     
     
    392408  protected function _assertResponseCode($response, $wanted) 
    393409  { 
    394     list($code, $separator, $text) = sscanf($response, '%3d%[ -]%s'); 
     410    list($code) = sscanf($response, '%3d'); 
    395411    $valid = (empty($wanted) || in_array($code, $wanted)); 
    396412     
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Transport/Esmtp/Authenticator.php'; 
    12 //@require 'Swift/Transport/SmtpAgent.php'; 
    13 //@require 'Swift/TransportException.php'; 
    1411 
    1512/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Transport/Esmtp/Authenticator.php'; 
    12 //@require 'Swift/Transport/SmtpAgent.php'; 
    13 //@require 'Swift/TransportException.php'; 
    1411 
    1512/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Transport/Esmtp/Authenticator.php'; 
    12 //@require 'Swift/Transport/SmtpAgent.php'; 
    13 //@require 'Swift/TransportException.php'; 
    1411 
    1512/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Transport/Esmtp/AuthHandler.php

    r22246 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/TransportException.php'; 
    12 //@require 'Swift/Transport/EsmtpHandler.php'; 
    13 //@require 'Swift/Transport/SmtpAgent.php'; 
    1411 
    1512/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Transport/Esmtp/Authenticator.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Transport/SmtpAgent.php'; 
    1211 
    1312/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Transport/EsmtpHandler.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Transport/EsmtpBufferWrapper.php'; 
    1211 
    1312/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Transport/EsmtpTransport.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Transport/AbstractSmtpTransport.php'; 
    12 //@require 'Swift/Transport/EsmtpHandler.php'; 
    13 //@require 'Swift/Transport/IoBuffer.php'; 
    14 //@require 'Swift/Transport/SmtpAgent.php'; 
    15 //@require 'Swift/TransportException.php'; 
    16 //@require 'Swift/Mime/Message.php'; 
    17 //@require 'Swift/Events/EventDispatcher.php'; 
    1811 
    1912/** 
     
    5346    'timeout' => 30, 
    5447    'blocking' => 1, 
     48    'tls' => false, 
    5549    'type' => Swift_Transport_IoBuffer::TYPE_SOCKET 
    5650    ); 
     
    7266   * Set the host to connect to. 
    7367   * @param string $host 
     68   * @return Swift_Transport_EsmtpTransport 
    7469   */ 
    7570  public function setHost($host) 
     
    9186   * Set the port to connect to. 
    9287   * @param int $port 
     88   * @return Swift_Transport_EsmtpTransport 
    9389   */ 
    9490  public function setPort($port) 
     
    110106   * Set the connection timeout. 
    111107   * @param int $timeout seconds 
     108   * @return Swift_Transport_EsmtpTransport 
    112109   */ 
    113110  public function setTimeout($timeout) 
    114111  { 
    115112    $this->_params['timeout'] = (int) $timeout; 
     113    $this->_buffer->setParam('timeout', (int) $timeout); 
    116114    return $this; 
    117115  } 
     
    129127   * Set the encryption type (tls or ssl) 
    130128   * @param string $encryption 
     129   * @return Swift_Transport_EsmtpTransport 
    131130   */ 
    132131  public function setEncryption($enc) 
    133132  { 
    134     $this->_params['protocol'] = $enc; 
     133    if ('tls' == $enc) 
     134    { 
     135      $this->_params['protocol'] = 'tcp'; 
     136      $this->_params['tls'] = true; 
     137    } else { 
     138      $this->_params['protocol'] = $enc; 
     139      $this->_params['tls'] = false; 
     140    } 
    135141    return $this; 
    136142  } 
     
    142148  public function getEncryption() 
    143149  { 
    144     return $this->_params['protocol']; 
     150    return $this->_params['tls'] ? 'tls' : $this->_params['protocol']; 
     151  } 
     152   
     153  /** 
     154   * Sets the sourceIp 
     155   * @param string $source 
     156   * @return Swift_Transport_EsmtpTransport 
     157   */ 
     158  public function setSourceIp($source) 
     159  { 
     160    $this->_params['sourceIp']=$source; 
     161    return $this; 
     162  } 
     163 
     164  /** 
     165   * Returns the ip used to connect to the destination 
     166   * @return string 
     167   */ 
     168  public function getSourceIp() 
     169  { 
     170    return $this->_params['sourceIp']; 
    145171  } 
    146172   
     
    148174   * Set ESMTP extension handlers. 
    149175   * @param Swift_Transport_EsmtpHandler[] $handlers 
     176   * @return Swift_Transport_EsmtpTransport 
    150177   */ 
    151178  public function setExtensionHandlers(array $handlers) 
     
    240267        sprintf("EHLO %s\r\n", $this->_domain), array(250) 
    241268        ); 
    242       $this->_capabilities = $this->_getCapabilities($response); 
    243       $this->_setHandlerParams(); 
    244       foreach ($this->_getActiveHandlers() as $handler) 
    245       { 
    246         $handler->afterEhlo($this); 
    247       } 
    248269    } 
    249270    catch (Swift_TransportException $e) 
    250271    { 
    251       parent::_doHeloCommand(); 
     272      return parent::_doHeloCommand(); 
     273    } 
     274 
     275    if ($this->_params['tls']) 
     276    { 
     277      try 
     278      { 
     279        $this->executeCommand("STARTTLS\r\n", array(220)); 
     280         
     281        if (!$this->_buffer->startTLS()) 
     282        { 
     283          throw new Swift_TransportException('Unable to connect with TLS encryption'); 
     284        } 
     285         
     286        try 
     287        { 
     288          $response = $this->executeCommand( 
     289            sprintf("EHLO %s\r\n", $this->_domain), array(250) 
     290            ); 
     291        } 
     292        catch (Swift_TransportException $e) 
     293        { 
     294          return parent::_doHeloCommand(); 
     295        } 
     296      } 
     297      catch (Swift_TransportException $e) 
     298      { 
     299        $this->_throwException($e); 
     300      } 
     301    } 
     302 
     303    $this->_capabilities = $this->_getCapabilities($response); 
     304    $this->_setHandlerParams(); 
     305    foreach ($this->_getActiveHandlers() as $handler) 
     306    { 
     307      $handler->afterEhlo($this); 
    252308    } 
    253309  } 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Transport/FailoverTransport.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Transport/LoadBalancedTransport.php'; 
    12 //@require 'Swift/Mime/Message.php'; 
    1311 
    1412/** 
     
    3937  /** 
    4038   * Send the given Message. 
    41    * Recipient/sender data will be retreived from the Message API. 
     39   * Recipient/sender data will be retrieved from the Message API. 
    4240   * The return value is the number of recipients who were accepted for delivery. 
    4341   * @param Swift_Mime_Message $message 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Transport/IoBuffer.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/InputByteStream.php'; 
    12 //@require 'Swift/OutputByteStream.php'; 
    1311 
    1412/** 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Transport/LoadBalancedTransport.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Transport.php'; 
    12 //@require 'Swift/Mime/Message.php'; 
    13 //@require 'Swift/Events/EventListener.php'; 
    1411 
    1512/** 
     
    5754   * @return array Swift_Transport 
    5855   */ 
    59   public function getTransports(array $transports
     56  public function getTransports(
    6057  { 
    6158    return array_merge($this->_transports, $this->_deadTransports); 
     
    9491   * Send the given Message. 
    9592   *  
    96    * Recipient/sender data will be retreived from the Message API. 
     93   * Recipient/sender data will be retrieved from the Message API. 
    9794   * The return value is the number of recipients who were accepted for delivery. 
    9895   *  
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Transport/MailTransport.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Transport.php'; 
    12 //@require 'Swift/Transport/MailInvoker.php'; 
    13 //@require 'Swift/Mime/Message.php'; 
    14 //@require 'Swift/Events/EventListener.php'; 
    1511 
    1612/** 
     
    8076   *  
    8177   * @param string $params 
     78   * @return Swift_Transport_MailTransport 
    8279   */ 
    8380  public function setExtraParams($params) 
     
    10299   * Send the given Message. 
    103100   *  
    104    * Recipient/sender data will be retreived from the Message API. 
     101   * Recipient/sender data will be retrieved from the Message API. 
    105102   * The return value is the number of recipients who were accepted for delivery. 
    106103   *  
     
    131128    $subjectHeader = $message->getHeaders()->get('Subject'); 
    132129     
     130    if (!$toHeader) 
     131    { 
     132      throw new Swift_TransportException( 
     133        'Cannot send message without a recipient' 
     134        ); 
     135    } 
    133136    $to = $toHeader->getFieldBody(); 
    134     $subject = $subjectHeader->getFieldBody()
     137    $subject = $subjectHeader ? $subjectHeader->getFieldBody() : ''
    135138     
    136139    $reversePath = $this->_getReversePath($message); 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Transport/SendmailTransport.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/Transport/EsmtpTransport.php'; 
    12 //@require 'Swift/Transport/IoBuffer.php'; 
    13 //@require 'Swift/Transport/Log.php'; 
    14 //@require 'Swift/Events/EventDispatcher.php'; 
    1511 
    1612/** 
     
    7167   * are hence possible. 
    7268   * @param string $command 
     69   * @return Swift_Transport_SendmailTransport 
    7370   */ 
    7471  public function setCommand($command) 
     
    8986  /** 
    9087   * Send the given Message. 
    91    * Recipient/sender data will be retreived from the Message API. 
     88   * Recipient/sender data will be retrieved from the Message API. 
    9289   * The return value is the number of recipients who were accepted for delivery. 
    9390   * NOTE: If using 'sendmail -t' you will not be aware of any failures until 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Transport/SimpleMailInvoker.php

    r21808 r33569  
    1919 */ 
    2020  
    21 //@require 'Swift/Transport/MailInvoker.php'; 
    2221 
    2322/** 
     
    4847    if (!ini_get('safe_mode')) 
    4948    { 
    50       return mail($to, $subject, $body, $headers, $extraParams); 
     49      return @mail($to, $subject, $body, $headers, $extraParams); 
    5150    } 
    5251    else 
    5352    { 
    54       return mail($to, $subject, $body, $headers);       
     53      return @mail($to, $subject, $body, $headers);       
    5554    } 
    5655  } 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Transport/SpoolTransport.php

    r22247 r33569  
    3434   * Sets the spool object. 
    3535   * @param Swift_Spool $spool 
     36   * @return Swift_Transport_SpoolTransport 
    3637   */ 
    3738  public function setSpool(Swift_Spool $spool) 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/Transport/StreamBuffer.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/ByteStream/AbstractFilterableInputStream.php'; 
    12 //@require 'Swift/ReplacementFilterFactory.php'; 
    13 //@require 'Swift/Transport/IoBuffer.php'; 
    14 //@require 'Swift/TransportException.php'; 
    1511 
    1612/** 
     
    8480      switch ($param) 
    8581      { 
    86         case 'protocol': 
    87           if (!array_key_exists('protocol', $this->_params) 
    88             || $value != $this->_params['protocol']) 
     82        case 'timeout': 
     83          if ($this->_stream) 
    8984          { 
    90             if ('tls' == $value) 
    91             { 
    92               stream_socket_enable_crypto( 
    93                 $this->_stream, true, STREAM_CRYPTO_METHOD_TLS_CLIENT 
    94                 ); 
    95             } 
     85            stream_set_timeout($this->_stream, $value); 
    9686          } 
    9787          break; 
     88           
     89        case 'blocking': 
     90          if ($this->_stream) 
     91          { 
     92            stream_set_blocking($this->_stream, 1); 
     93          } 
     94           
    9895      } 
    9996    } 
    10097    $this->_params[$param] = $value; 
     98  } 
     99   
     100  public function startTLS() 
     101  { 
     102    return stream_socket_enable_crypto($this->_stream, true, STREAM_CRYPTO_METHOD_TLS_CLIENT); 
    101103  } 
    102104   
     
    166168    { 
    167169      $line = fgets($this->_out); 
     170      if (strlen($line)==0)  
     171      { 
     172        $metas = stream_get_meta_data($this->_out); 
     173        if ($metas['timed_out']) { 
     174          throw new Swift_IoException( 
     175            'Connection to ' .  
     176              $this->_getReadConnectionDescription() .  
     177            ' Timed Out' 
     178          ); 
     179        } 
     180      } 
    168181      return $line; 
    169182    } 
     
    183196    { 
    184197      $ret = fread($this->_out, $length); 
     198      if (strlen($ret)==0)  
     199      { 
     200        $metas = stream_get_meta_data($this->_out); 
     201        if ($metas['timed_out'])  
     202        { 
     203          throw new Swift_IoException( 
     204            'Connection to ' .  
     205              $this->_getReadConnectionDescription() .  
     206            ' Timed Out' 
     207          ); 
     208        } 
     209      } 
    185210      return $ret; 
    186211    } 
     
    231256      $timeout = $this->_params['timeout']; 
    232257    } 
    233     if (!$this->_stream = fsockopen($host, $this->_params['port'], $errno, $errstr, $timeout)) 
     258    $options = array(); 
     259    if (!empty($this->_params['sourceIp'])) 
     260    { 
     261      $options['socket']['bindto']=$this->_params['sourceIp'].':0'; 
     262    } 
     263    $this->_stream = @stream_socket_client($host.':'.$this->_params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, stream_context_create($options)); 
     264    if (false === $this->_stream) 
    234265    { 
    235266      throw new Swift_TransportException( 
     
    246277      stream_set_blocking($this->_stream, 0); 
    247278    } 
     279    stream_set_timeout($this->_stream, $timeout); 
    248280    $this->_in =& $this->_stream; 
    249281    $this->_out =& $this->_stream; 
     
    274306  } 
    275307   
     308   
     309  private function _getReadConnectionDescription() 
     310  { 
     311    switch ($this->_params['type']) 
     312    { 
     313      case self::TYPE_PROCESS: 
     314        return 'Process '.$this->_params['command']; 
     315        break; 
     316         
     317      case self::TYPE_SOCKET: 
     318      default: 
     319        $host = $this->_params['host']; 
     320        if (!empty($this->_params['protocol'])) 
     321        { 
     322          $host = $this->_params['protocol'] . '://' . $host; 
     323        } 
     324        $host.=':'.$this->_params['port']; 
     325        return $host; 
     326        break; 
     327    } 
     328  } 
    276329} 
  • branches/1.4/lib/vendor/swiftmailer/classes/Swift/TransportException.php

    r21985 r33569  
    99 */ 
    1010 
    11 //@require 'Swift/IoException.php'; 
    1211 
    1312/** 
  • branches/1.4/lib/vendor/swiftmailer/dependency_maps/mime_deps.php

    r22246 r33569  
    11<?php 
    22 
    3 require_once dirname(__FILE__) . '/../mime_types.php'; 
     3require dirname(__FILE__) . '/../mime_types.php'; 
    44 
    55Swift_DependencyContainer::getInstance() 
     
    77  -> register('properties.charset') 
    88  -> asValue('utf-8') 
     9   
     10  -> register('mime.grammar') 
     11  -> asSharedInstanceOf('Swift_Mime_Grammar') 
    912   
    1013  -> register('mime.message') 
     
    1417    'mime.qpcontentencoder', 
    1518    'cache', 
     19    'mime.grammar', 
    1620    'properties.charset' 
    1721  )) 
     
    2327    'mime.qpcontentencoder', 
    2428    'cache', 
     29    'mime.grammar', 
    2530    'properties.charset' 
    2631  )) 
     
    3136    'mime.headerset', 
    3237    'mime.base64contentencoder', 
    33     'cache' 
     38    'cache', 
     39    'mime.grammar' 
    3440  )) 
    3541  -> addConstructorValue($swift_mime_types) 
     
    4046    'mime.headerset', 
    4147    'mime.base64contentencoder', 
    42     'cache' 
     48    'cache', 
     49    'mime.grammar' 
    4350  )) 
    4451  -> addConstructorValue($swift_mime_types) 
     
    4956      'mime.qpheaderencoder', 
    5057      'mime.rfc2231encoder', 
     58      'mime.grammar', 
    5159      'properties.charset' 
    5260    )) 
  • branches/1.4/lib/vendor/swiftmailer/preferences.php

    r21808 r33569  
    1010Swift_Preferences::getInstance()->setCharset('utf-8'); 
    1111 
    12 // Without these lines the default caching mechanism is "array" but this uses 
    13 // a lot of memory
    14 // If possible, use a disk cache to enable attaching large attachments etc 
     12// Without these lines the default caching mechanism is "array" but this uses a lot of memory. 
     13// If possible, use a disk cache to enable attaching large attachments etc
     14// You can override the default temporary directory by setting the TMPDIR environment variable. 
    1515if (function_exists('sys_get_temp_dir') && is_writable(sys_get_temp_dir())) 
    1616{ 
     
    1919    -> setCacheType('disk'); 
    2020} 
     21 
     22Swift_Preferences::getInstance()->setQPDotEscape(false); 
  • branches/1.4/lib/vendor/swiftmailer/swift_init.php

    r21985 r33569  
    1313 */ 
    1414 
     15if (defined('SWIFT_INIT_LOADED')) 
     16  return; 
     17 
     18define('SWIFT_INIT_LOADED', true); 
     19 
    1520//Load in dependency maps 
    16 require_once dirname(__FILE__) . '/dependency_maps/cache_deps.php'; 
    17 require_once dirname(__FILE__) . '/dependency_maps/mime_deps.php'; 
    18 require_once dirname(__FILE__) . '/dependency_maps/transport_deps.php'; 
     21require dirname(__FILE__) . '/dependency_maps/cache_deps.php'; 
     22require dirname(__FILE__) . '/dependency_maps/mime_deps.php'; 
     23require dirname(__FILE__) . '/dependency_maps/message_deps.php'; 
     24require dirname(__FILE__) . '/dependency_maps/transport_deps.php'; 
    1925 
    2026//Load in global library preferences 
    21 require_once dirname(__FILE__) . '/preferences.php'; 
     27require dirname(__FILE__) . '/preferences.php'; 
  • branches/1.4/lib/vendor/swiftmailer/swift_required.php

    r21985 r33569  
    1313 */ 
    1414 
     15if (defined('SWIFT_REQUIRED_LOADED')) 
     16  return; 
     17 
     18define('SWIFT_REQUIRED_LOADED', true); 
     19 
    1520//Load Swift utility class 
    16 require_once dirname(__FILE__) . '/classes/Swift.php'; 
     21require dirname(__FILE__) . '/classes/Swift.php'; 
    1722 
    18 //Start the autoloader 
    19 Swift::registerAutoload(); 
    20  
    21 //Load the init script to set up dependency injection 
    22 require_once dirname(__FILE__) . '/swift_init.php'; 
     23//Start the autoloader and lazy-load the init script to set up dependency injection 
     24Swift::registerAutoload(dirname(__FILE__) . '/swift_init.php'); 
  • branches/1.4/lib/vendor/swiftmailer/swift_required_pear.php

    r23762 r33569  
    1313 */ 
    1414 
     15if (defined('SWIFT_REQUIRED_LOADED')) 
     16  return; 
     17 
     18define('SWIFT_REQUIRED_LOADED', true); 
     19 
    1520//Load Swift utility class 
    16 require_once dirname(__FILE__) . '/Swift.php'; 
     21require dirname(__FILE__) . '/Swift.php'; 
    1722 
    1823//Start the autoloader 
     
    2025 
    2126//Load the init script to set up dependency injection 
    22 require_once dirname(__FILE__) . '/swift_init.php'; 
     27require dirname(__FILE__) . '/swift_init.php';