Current file: htdocs/lib/Zend/Mail.php
Legend: executed not executed dead code

  Coverage
  Classes Functions / Methods Lines
Total
0.00%0.00%
0.00% 0 / 1
32.81%32.81%
32.81% 21 / 64 CRAP
46.95%46.95%
46.95% 146 / 311
 
Zend_Mail
0.00%0.00%
0.00% 0 / 1
32.81%32.81%
32.81% 21 / 64
46.95%46.95%
46.95% 146 / 311
 setDefaultTransport(Zend_Mail_Transport_Abstract $transport)
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 2
 getDefaultTransport()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 1
 clearDefaultTransport()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 2
 __construct($charset = null)
100.00%100.00%
100.00% 1 / 1 2
100.00%100.00%
100.00% 4 / 4
 getCharset()
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 1 / 1
 setType($type)
0.00%0.00%
0.00% 0 / 1 2.01
87.50%87.50%
87.50% 7 / 8
 getType()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 1
 setMimeBoundary($boundary)
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 2 / 2
 getMimeBoundary()
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 1 / 1
 getEncodingOfHeaders()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 1
 getHeaderEncoding()
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 1 / 1
 setEncodingOfHeaders($encoding)
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 1
 setHeaderEncoding($encoding)
0.00%0.00%
0.00% 0 / 1 2.02
83.33%83.33%
83.33% 5 / 6
 setBodyText($txt, $charset = null, $encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE)
100.00%100.00%
100.00% 1 / 1 2
100.00%100.00%
100.00% 10 / 10
 getBodyText($textOnly = false)
0.00%0.00%
0.00% 0 / 1 12
0.00%0.00%
0.00% 0 / 4
 setBodyHtml($html, $charset = null, $encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE)
100.00%100.00%
100.00% 1 / 1 2
100.00%100.00%
100.00% 10 / 10
 getBodyHtml($htmlOnly = false)
100.00%100.00%
100.00% 1 / 1 3
100.00%100.00%
100.00% 4 / 4
 addAttachment(Zend_Mime_Part $attachment)
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 3 / 3
 createAttachment($body, $mimeType = Zend_Mime::TYPE_OCTETSTREAM, $disposition = Zend_Mime::DISPOSITION_ATTACHMENT, $encoding = Zend_Mime::ENCODING_BASE64, $filename = null)
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 7 / 7
 getPartCount()
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 1 / 1
 _encodeHeader($value)
0.00%0.00%
0.00% 0 / 1 6.28
28.57%28.57%
28.57% 2 / 7
 _storeHeader($headerName, $value, $append = false)
0.00%0.00%
0.00% 0 / 1 3.14
75.00%75.00%
75.00% 6 / 8
 _clearHeader($headerName)
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 2
 _addRecipientAndHeader($headerName, $email, $name)
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 5 / 5
 addTo($email, $name='')
100.00%100.00%
100.00% 1 / 1 4
100.00%100.00%
100.00% 8 / 8
 addCc($email, $name='')
0.00%0.00%
0.00% 0 / 1 20
0.00%0.00%
0.00% 0 / 7
 addBcc($email)
0.00%0.00%
0.00% 0 / 1 12
0.00%0.00%
0.00% 0 / 7
 getRecipients()
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 1 / 1
 clearHeader($headerName)
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 4
 clearRecipients()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 6
 setFrom($email, $name = null)
0.00%0.00%
0.00% 0 / 1 2.01
85.71%85.71%
85.71% 6 / 7
 setReplyTo($email, $name = null)
0.00%0.00%
0.00% 0 / 1 2.01
85.71%85.71%
85.71% 6 / 7
 getFrom()
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 1 / 1
 getReplyTo()
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 1 / 1
 clearFrom()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 3
 clearReplyTo()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 3
 setDefaultFrom($email, $name = null)
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 2
 getDefaultFrom()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 1
 clearDefaultFrom()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 2
 setFromToDefaultFrom()
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 6
 setDefaultReplyTo($email, $name = null)
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 2
 getDefaultReplyTo()
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 1 / 1
 clearDefaultReplyTo()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 2
 setReplyToFromDefault()
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 6
 setReturnPath($email)
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 7
 getReturnPath()
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 3
 clearReturnPath()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 3
 setSubject($subject)
0.00%0.00%
0.00% 0 / 1 2.01
85.71%85.71%
85.71% 6 / 7
 getSubject()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 1
 clearSubject()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 3
 setDate($date = null)
0.00%0.00%
0.00% 0 / 1 23.18
38.10%38.10%
38.10% 8 / 21
 getDate()
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 1 / 1
 clearDate()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 3
 setMessageId($id = true)
0.00%0.00%
0.00% 0 / 1 30
0.00%0.00%
0.00% 0 / 12
 getMessageId()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 1
 clearMessageId()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 3
 createMessageId()
0.00%0.00%
0.00% 0 / 1 30
0.00%0.00%
0.00% 0 / 17
 addHeader($name, $value, $append = false)
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 10
 getHeaders()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 1
 send($transport = null)
0.00%0.00%
0.00% 0 / 1 17.50
47.06%47.06%
47.06% 8 / 17
 _filterEmail($email)
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 9 / 9
 _filterName($name)
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 8 / 8
 _filterOther($data)
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 5 / 5
 _formatAddress($email, $name)
0.00%0.00%
0.00% 0 / 1 7.54
77.78%77.78%
77.78% 7 / 9


       1                 : <?php                                                                                                                                   
       2                 : /**                                                                                                                                     
       3                 :  * Zend Framework                                                                                                                       
       4                 :  *                                                                                                                                      
       5                 :  * LICENSE                                                                                                                              
       6                 :  *                                                                                                                                      
       7                 :  * This source file is subject to the new BSD license that is bundled                                                                   
       8                 :  * with this package in the file LICENSE.txt.                                                                                           
       9                 :  * It is also available through the world-wide-web at this URL:                                                                         
      10                 :  * http://framework.zend.com/license/new-bsd                                                                                            
      11                 :  * If you did not receive a copy of the license and are unable to                                                                       
      12                 :  * obtain it through the world-wide-web, please send an email                                                                           
      13                 :  * to license@zend.com so we can send you a copy immediately.                                                                           
      14                 :  *                                                                                                                                      
      15                 :  * @category   Zend                                                                                                                     
      16                 :  * @package    Zend_Mail                                                                                                                
      17                 :  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)                                                 
      18                 :  * @license    http://framework.zend.com/license/new-bsd     New BSD License                                                            
      19                 :  * @version    $Id: Mail.php 23251 2010-10-26 12:47:55Z matthew $                                                                       
      20                 :  */                                                                                                                                     
      21                 :                                                                                                                                         
      22                 :                                                                                                                                         
      23                 : /**                                                                                                                                     
      24                 :  * @see Zend_Mail_Transport_Abstract                                                                                                    
      25                 :  */                                                                                                                                     
      26                 : #require_once 'Zend/Mail/Transport/Abstract.php';                                                                                       
      27                 :                                                                                                                                         
      28                 : /**                                                                                                                                     
      29                 :  * @see Zend_Mime                                                                                                                       
      30                 :  */                                                                                                                                     
      31                 : #require_once 'Zend/Mime.php';                                                                                                          
      32                 :                                                                                                                                         
      33                 : /**                                                                                                                                     
      34                 :  * @see Zend_Mime_Message                                                                                                               
      35                 :  */                                                                                                                                     
      36                 : #require_once 'Zend/Mime/Message.php';                                                                                                  
      37                 :                                                                                                                                         
      38                 : /**                                                                                                                                     
      39                 :  * @see Zend_Mime_Part                                                                                                                  
      40                 :  */                                                                                                                                     
      41                 : #require_once 'Zend/Mime/Part.php';                                                                                                     
      42                 :                                                                                                                                         
      43                 :                                                                                                                                         
      44                 : /**                                                                                                                                     
      45                 :  * Class for sending an email.                                                                                                          
      46                 :  *                                                                                                                                      
      47                 :  * @category   Zend                                                                                                                     
      48                 :  * @package    Zend_Mail                                                                                                                
      49                 :  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)                                                 
      50                 :  * @license    http://framework.zend.com/license/new-bsd     New BSD License                                                            
      51                 :  */                                                                                                                                     
      52                 : class Zend_Mail extends Zend_Mime_Message                                                                                               
      53               1 : {                                                                                                                                       
      54                 :     /**#@+                                                                                                                              
      55                 :      * @access protected                                                                                                                
      56                 :      */                                                                                                                                 
      57                 :                                                                                                                                         
      58                 :     /**                                                                                                                                 
      59                 :      * @var Zend_Mail_Transport_Abstract                                                                                                
      60                 :      * @static                                                                                                                          
      61                 :      */                                                                                                                                 
      62                 :     protected static $_defaultTransport = null;                                                                                         
      63                 :                                                                                                                                         
      64                 :     /**                                                                                                                                 
      65                 :      * @var array                                                                                                                       
      66                 :      * @static                                                                                                                          
      67                 :      */                                                                                                                                 
      68                 :     protected static $_defaultFrom;                                                                                                     
      69                 :                                                                                                                                         
      70                 :     /**                                                                                                                                 
      71                 :      * @var array                                                                                                                       
      72                 :      * @static                                                                                                                          
      73                 :      */                                                                                                                                 
      74                 :     protected static $_defaultReplyTo;                                                                                                  
      75                 :                                                                                                                                         
      76                 :     /**                                                                                                                                 
      77                 :      * Mail character set                                                                                                               
      78                 :      * @var string                                                                                                                      
      79                 :      */                                                                                                                                 
      80                 :     protected $_charset = 'iso-8859-1';                                                                                                 
      81                 :                                                                                                                                         
      82                 :     /**                                                                                                                                 
      83                 :      * Mail headers                                                                                                                     
      84                 :      * @var array                                                                                                                       
      85                 :      */                                                                                                                                 
      86                 :     protected $_headers = array();                                                                                                      
      87                 :                                                                                                                                         
      88                 :     /**                                                                                                                                 
      89                 :      * Encoding of Mail headers                                                                                                         
      90                 :      * @var string                                                                                                                      
      91                 :      */                                                                                                                                 
      92                 :     protected $_headerEncoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE;                                                                   
      93                 :                                                                                                                                         
      94                 :     /**                                                                                                                                 
      95                 :      * From: address                                                                                                                    
      96                 :      * @var string                                                                                                                      
      97                 :      */                                                                                                                                 
      98                 :     protected $_from = null;                                                                                                            
      99                 :                                                                                                                                         
     100                 :     /**                                                                                                                                 
     101                 :      * To: addresses                                                                                                                    
     102                 :      * @var array                                                                                                                       
     103                 :      */                                                                                                                                 
     104                 :     protected $_to = array();                                                                                                           
     105                 :                                                                                                                                         
     106                 :     /**                                                                                                                                 
     107                 :      * Array of all recipients                                                                                                          
     108                 :      * @var array                                                                                                                       
     109                 :      */                                                                                                                                 
     110                 :     protected $_recipients = array();                                                                                                   
     111                 :                                                                                                                                         
     112                 :     /**                                                                                                                                 
     113                 :      * Reply-To header                                                                                                                  
     114                 :      * @var string                                                                                                                      
     115                 :      */                                                                                                                                 
     116                 :     protected $_replyTo = null;                                                                                                         
     117                 :                                                                                                                                         
     118                 :     /**                                                                                                                                 
     119                 :      * Return-Path header                                                                                                               
     120                 :      * @var string                                                                                                                      
     121                 :      */                                                                                                                                 
     122                 :     protected $_returnPath = null;                                                                                                      
     123                 :                                                                                                                                         
     124                 :     /**                                                                                                                                 
     125                 :      * Subject: header                                                                                                                  
     126                 :      * @var string                                                                                                                      
     127                 :      */                                                                                                                                 
     128                 :     protected $_subject = null;                                                                                                         
     129                 :                                                                                                                                         
     130                 :     /**                                                                                                                                 
     131                 :      * Date: header                                                                                                                     
     132                 :      * @var string                                                                                                                      
     133                 :      */                                                                                                                                 
     134                 :     protected $_date = null;                                                                                                            
     135                 :                                                                                                                                         
     136                 :     /**                                                                                                                                 
     137                 :      * Message-ID: header                                                                                                               
     138                 :      * @var string                                                                                                                      
     139                 :      */                                                                                                                                 
     140                 :     protected $_messageId = null;                                                                                                       
     141                 :                                                                                                                                         
     142                 :     /**                                                                                                                                 
     143                 :      * text/plain MIME part                                                                                                             
     144                 :      * @var false|Zend_Mime_Part                                                                                                        
     145                 :      */                                                                                                                                 
     146                 :     protected $_bodyText = false;                                                                                                       
     147                 :                                                                                                                                         
     148                 :     /**                                                                                                                                 
     149                 :      * text/html MIME part                                                                                                              
     150                 :      * @var false|Zend_Mime_Part                                                                                                        
     151                 :      */                                                                                                                                 
     152                 :     protected $_bodyHtml = false;                                                                                                       
     153                 :                                                                                                                                         
     154                 :     /**                                                                                                                                 
     155                 :      * MIME boundary string                                                                                                             
     156                 :      * @var string                                                                                                                      
     157                 :      */                                                                                                                                 
     158                 :     protected $_mimeBoundary = null;                                                                                                    
     159                 :                                                                                                                                         
     160                 :     /**                                                                                                                                 
     161                 :      * Content type of the message                                                                                                      
     162                 :      * @var string                                                                                                                      
     163                 :      */                                                                                                                                 
     164                 :     protected $_type = null;                                                                                                            
     165                 :                                                                                                                                         
     166                 :     /**#@-*/                                                                                                                            
     167                 :                                                                                                                                         
     168                 :     /**                                                                                                                                 
     169                 :      * Flag: whether or not email has attachments                                                                                       
     170                 :      * @var boolean                                                                                                                     
     171                 :      */                                                                                                                                 
     172                 :     public $hasAttachments = false;                                                                                                     
     173                 :                                                                                                                                         
     174                 :                                                                                                                                         
     175                 :     /**                                                                                                                                 
     176                 :      * Sets the default mail transport for all following uses of                                                                        
     177                 :      * Zend_Mail::send();                                                                                                               
     178                 :      *                                                                                                                                  
     179                 :      * @todo Allow passing a string to indicate the transport to load                                                                   
     180                 :      * @todo Allow passing in optional options for the transport to load                                                                
     181                 :      * @param  Zend_Mail_Transport_Abstract $transport                                                                                  
     182                 :      */                                                                                                                                 
     183                 :     public static function setDefaultTransport(Zend_Mail_Transport_Abstract $transport)                                                 
     184                 :     {                                                                                                                                   
     185               0 :         self::$_defaultTransport = $transport;                                                                                          
     186               0 :     }                                                                                                                                   
     187                 :                                                                                                                                         
     188                 :     /**                                                                                                                                 
     189                 :      * Gets the default mail transport for all following uses of                                                                        
     190                 :      * unittests                                                                                                                        
     191                 :      *                                                                                                                                  
     192                 :      * @todo Allow passing a string to indicate the transport to load                                                                   
     193                 :      * @todo Allow passing in optional options for the transport to load                                                                
     194                 :      */                                                                                                                                 
     195                 :     public static function getDefaultTransport()                                                                                        
     196                 :     {                                                                                                                                   
     197               0 :         return self::$_defaultTransport;                                                                                                
     198                 :     }                                                                                                                                   
     199                 :                                                                                                                                         
     200                 :     /**                                                                                                                                 
     201                 :      * Clear the default transport property                                                                                             
     202                 :      */                                                                                                                                 
     203                 :     public static function clearDefaultTransport()                                                                                      
     204                 :     {                                                                                                                                   
     205               0 :         self::$_defaultTransport = null;                                                                                                
     206               0 :     }                                                                                                                                   
     207                 :                                                                                                                                         
     208                 :     /**                                                                                                                                 
     209                 :      * Public constructor                                                                                                               
     210                 :      *                                                                                                                                  
     211                 :      * @param  string $charset                                                                                                          
     212                 :      * @return void                                                                                                                     
     213                 :      */                                                                                                                                 
     214                 :     public function __construct($charset = null)                                                                                        
     215                 :     {                                                                                                                                   
     216              10 :         if ($charset != null) {                                                                                                         
     217               3 :             $this->_charset = $charset;                                                                                                 
     218               3 :         }                                                                                                                               
     219              10 :     }                                                                                                                                   
     220                 :                                                                                                                                         
     221                 :     /**                                                                                                                                 
     222                 :      * Return charset string                                                                                                            
     223                 :      *                                                                                                                                  
     224                 :      * @return string                                                                                                                   
     225                 :      */                                                                                                                                 
     226                 :     public function getCharset()                                                                                                        
     227                 :     {                                                                                                                                   
     228               1 :         return $this->_charset;                                                                                                         
     229                 :     }                                                                                                                                   
     230                 :                                                                                                                                         
     231                 :     /**                                                                                                                                 
     232                 :      * Set content type                                                                                                                 
     233                 :      *                                                                                                                                  
     234                 :      * Should only be used for manually setting multipart content types.                                                                
     235                 :      *                                                                                                                                  
     236                 :      * @param  string $type Content type                                                                                                
     237                 :      * @return Zend_Mail Implements fluent interface                                                                                    
     238                 :      * @throws Zend_Mail_Exception for types not supported by Zend_Mime                                                                 
     239                 :      */                                                                                                                                 
     240                 :     public function setType($type)                                                                                                      
     241                 :     {                                                                                                                                   
     242                 :         $allowed = array(                                                                                                               
     243               4 :             Zend_Mime::MULTIPART_ALTERNATIVE,                                                                                           
     244               4 :             Zend_Mime::MULTIPART_MIXED,                                                                                                 
     245               4 :             Zend_Mime::MULTIPART_RELATED,                                                                                               
     246               4 :         );                                                                                                                              
     247               4 :         if (!in_array($type, $allowed)) {                                                                                               
     248                 :             /**                                                                                                                         
     249                 :              * @see Zend_Mail_Exception                                                                                                 
     250                 :              */                                                                                                                         
     251                 :             #require_once 'Zend/Mail/Exception.php';                                                                                    
     252               0 :             throw new Zend_Mail_Exception('Invalid content type "' . $type . '"');                                                      
     253                 :         }                                                                                                                               
     254                 :                                                                                                                                         
     255               4 :         $this->_type = $type;                                                                                                           
     256               4 :         return $this;                                                                                                                   
     257                 :     }                                                                                                                                   
     258                 :                                                                                                                                         
     259                 :     /**                                                                                                                                 
     260                 :      * Get content type of the message                                                                                                  
     261                 :      *                                                                                                                                  
     262                 :      * @return string                                                                                                                   
     263                 :      */                                                                                                                                 
     264                 :     public function getType()                                                                                                           
     265                 :     {                                                                                                                                   
     266               0 :         return $this->_type;                                                                                                            
     267                 :     }                                                                                                                                   
     268                 :                                                                                                                                         
     269                 :     /**                                                                                                                                 
     270                 :      * Set an arbitrary mime boundary for the message                                                                                   
     271                 :      *                                                                                                                                  
     272                 :      * If not set, Zend_Mime will generate one.                                                                                         
     273                 :      *                                                                                                                                  
     274                 :      * @param  string    $boundary                                                                                                      
     275                 :      * @return Zend_Mail Provides fluent interface                                                                                      
     276                 :      */                                                                                                                                 
     277                 :     public function setMimeBoundary($boundary)                                                                                          
     278                 :     {                                                                                                                                   
     279               1 :         $this->_mimeBoundary = $boundary;                                                                                               
     280                 :                                                                                                                                         
     281               1 :         return $this;                                                                                                                   
     282                 :     }                                                                                                                                   
     283                 :                                                                                                                                         
     284                 :     /**                                                                                                                                 
     285                 :      * Return the boundary string used for the message                                                                                  
     286                 :      *                                                                                                                                  
     287                 :      * @return string                                                                                                                   
     288                 :      */                                                                                                                                 
     289                 :     public function getMimeBoundary()                                                                                                   
     290                 :     {                                                                                                                                   
     291               1 :         return $this->_mimeBoundary;                                                                                                    
     292                 :     }                                                                                                                                   
     293                 :                                                                                                                                         
     294                 :     /**                                                                                                                                 
     295                 :      * Return encoding of mail headers                                                                                                  
     296                 :      *                                                                                                                                  
     297                 :      * @deprecated use {@link getHeaderEncoding()} instead                                                                              
     298                 :      * @return string                                                                                                                   
     299                 :      */                                                                                                                                 
     300                 :     public function getEncodingOfHeaders()                                                                                              
     301                 :     {                                                                                                                                   
     302               0 :         return $this->getHeaderEncoding();                                                                                              
     303                 :     }                                                                                                                                   
     304                 :                                                                                                                                         
     305                 :     /**                                                                                                                                 
     306                 :      * Return the encoding of mail headers                                                                                              
     307                 :      *                                                                                                                                  
     308                 :      * Either Zend_Mime::ENCODING_QUOTEDPRINTABLE or Zend_Mime::ENCODING_BASE64                                                         
     309                 :      *                                                                                                                                  
     310                 :      * @return string                                                                                                                   
     311                 :      */                                                                                                                                 
     312                 :     public function getHeaderEncoding()                                                                                                 
     313                 :     {                                                                                                                                   
     314               1 :         return $this->_headerEncoding;                                                                                                  
     315                 :     }                                                                                                                                   
     316                 :                                                                                                                                         
     317                 :     /**                                                                                                                                 
     318                 :      * Set the encoding of mail headers                                                                                                 
     319                 :      *                                                                                                                                  
     320                 :      * @deprecated Use {@link setHeaderEncoding()} instead.                                                                             
     321                 :      * @param  string $encoding                                                                                                         
     322                 :      * @return Zend_Mail                                                                                                                
     323                 :      */                                                                                                                                 
     324                 :     public function setEncodingOfHeaders($encoding)                                                                                     
     325                 :     {                                                                                                                                   
     326               0 :         return $this->setHeaderEncoding($encoding);                                                                                     
     327                 :     }                                                                                                                                   
     328                 :                                                                                                                                         
     329                 :     /**                                                                                                                                 
     330                 :      * Set the encoding of mail headers                                                                                                 
     331                 :      *                                                                                                                                  
     332                 :      * @param  string $encoding Zend_Mime::ENCODING_QUOTEDPRINTABLE or Zend_Mime::ENCODING_BASE64                                       
     333                 :      * @return Zend_Mail Provides fluent interface                                                                                      
     334                 :      */                                                                                                                                 
     335                 :     public function setHeaderEncoding($encoding)                                                                                        
     336                 :     {                                                                                                                                   
     337                 :         $allowed = array(                                                                                                               
     338               1 :             Zend_Mime::ENCODING_BASE64,                                                                                                 
     339                 :             Zend_Mime::ENCODING_QUOTEDPRINTABLE                                                                                         
     340               1 :         );                                                                                                                              
     341               1 :         if (!in_array($encoding, $allowed)) {                                                                                           
     342                 :             /**                                                                                                                         
     343                 :              * @see Zend_Mail_Exception                                                                                                 
     344                 :              */                                                                                                                         
     345                 :             #require_once 'Zend/Mail/Exception.php';                                                                                    
     346               0 :             throw new Zend_Mail_Exception('Invalid encoding "' . $encoding . '"');                                                      
     347                 :         }                                                                                                                               
     348               1 :         $this->_headerEncoding = $encoding;                                                                                             
     349                 :                                                                                                                                         
     350               1 :         return $this;                                                                                                                   
     351                 :     }                                                                                                                                   
     352                 :                                                                                                                                         
     353                 :     /**                                                                                                                                 
     354                 :      * Sets the text body for the message.                                                                                              
     355                 :      *                                                                                                                                  
     356                 :      * @param  string $txt                                                                                                              
     357                 :      * @param  string $charset                                                                                                          
     358                 :      * @param  string $encoding                                                                                                         
     359                 :      * @return Zend_Mail Provides fluent interface                                                                                      
     360                 :     */                                                                                                                                  
     361                 :     public function setBodyText($txt, $charset = null, $encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE)                                 
     362                 :     {                                                                                                                                   
     363               3 :         if ($charset === null) {                                                                                                        
     364               3 :             $charset = $this->_charset;                                                                                                 
     365               3 :         }                                                                                                                               
     366                 :                                                                                                                                         
     367               3 :         $mp = new Zend_Mime_Part($txt);                                                                                                 
     368               3 :         $mp->encoding = $encoding;                                                                                                      
     369               3 :         $mp->type = Zend_Mime::TYPE_TEXT;                                                                                               
     370               3 :         $mp->disposition = Zend_Mime::DISPOSITION_INLINE;                                                                               
     371               3 :         $mp->charset = $charset;                                                                                                        
     372                 :                                                                                                                                         
     373               3 :         $this->_bodyText = $mp;                                                                                                         
     374                 :                                                                                                                                         
     375               3 :         return $this;                                                                                                                   
     376                 :     }                                                                                                                                   
     377                 :                                                                                                                                         
     378                 :     /**                                                                                                                                 
     379                 :      * Return text body Zend_Mime_Part or string                                                                                        
     380                 :      *                                                                                                                                  
     381                 :      * @param  bool textOnly Whether to return just the body text content or the MIME part; defaults to false, the MIME part            
     382                 :      * @return false|Zend_Mime_Part|string                                                                                              
     383                 :      */                                                                                                                                 
     384                 :     public function getBodyText($textOnly = false)                                                                                      
     385                 :     {                                                                                                                                   
     386               0 :         if ($textOnly && $this->_bodyText) {                                                                                            
     387               0 :             $body = $this->_bodyText;                                                                                                   
     388               0 :             return $body->getContent();                                                                                                 
     389                 :         }                                                                                                                               
     390                 :                                                                                                                                         
     391               0 :         return $this->_bodyText;                                                                                                        
     392                 :     }                                                                                                                                   
     393                 :                                                                                                                                         
     394                 :     /**                                                                                                                                 
     395                 :      * Sets the HTML body for the message                                                                                               
     396                 :      *                                                                                                                                  
     397                 :      * @param  string    $html                                                                                                          
     398                 :      * @param  string    $charset                                                                                                       
     399                 :      * @param  string    $encoding                                                                                                      
     400                 :      * @return Zend_Mail Provides fluent interface                                                                                      
     401                 :      */                                                                                                                                 
     402                 :     public function setBodyHtml($html, $charset = null, $encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE)                                
     403                 :     {                                                                                                                                   
     404               4 :         if ($charset === null) {                                                                                                        
     405               4 :             $charset = $this->_charset;                                                                                                 
     406               4 :         }                                                                                                                               
     407                 :                                                                                                                                         
     408               4 :         $mp = new Zend_Mime_Part($html);                                                                                                
     409               4 :         $mp->encoding = $encoding;                                                                                                      
     410               4 :         $mp->type = Zend_Mime::TYPE_HTML;                                                                                               
     411               4 :         $mp->disposition = Zend_Mime::DISPOSITION_INLINE;                                                                               
     412               4 :         $mp->charset = $charset;                                                                                                        
     413                 :                                                                                                                                         
     414               4 :         $this->_bodyHtml = $mp;                                                                                                         
     415                 :                                                                                                                                         
     416               4 :         return $this;                                                                                                                   
     417                 :     }                                                                                                                                   
     418                 :                                                                                                                                         
     419                 :     /**                                                                                                                                 
     420                 :      * Return Zend_Mime_Part representing body HTML                                                                                     
     421                 :      *                                                                                                                                  
     422                 :      * @param  bool $htmlOnly Whether to return the body HTML only, or the MIME part; defaults to false, the MIME part                  
     423                 :      * @return false|Zend_Mime_Part|string                                                                                              
     424                 :      */                                                                                                                                 
     425                 :     public function getBodyHtml($htmlOnly = false)                                                                                      
     426                 :     {                                                                                                                                   
     427               4 :         if ($htmlOnly && $this->_bodyHtml) {                                                                                            
     428               1 :             $body = $this->_bodyHtml;                                                                                                   
     429               1 :             return $body->getContent();                                                                                                 
     430                 :         }                                                                                                                               
     431                 :                                                                                                                                         
     432               4 :         return $this->_bodyHtml;                                                                                                        
     433                 :     }                                                                                                                                   
     434                 :                                                                                                                                         
     435                 :     /**                                                                                                                                 
     436                 :      * Adds an existing attachment to the mail message                                                                                  
     437                 :      *                                                                                                                                  
     438                 :      * @param  Zend_Mime_Part $attachment                                                                                               
     439                 :      * @return Zend_Mail Provides fluent interface                                                                                      
     440                 :      */                                                                                                                                 
     441                 :     public function addAttachment(Zend_Mime_Part $attachment)                                                                           
     442                 :     {                                                                                                                                   
     443               4 :         $this->addPart($attachment);                                                                                                    
     444               4 :         $this->hasAttachments = true;                                                                                                   
     445                 :                                                                                                                                         
     446               4 :         return $this;                                                                                                                   
     447                 :     }                                                                                                                                   
     448                 :                                                                                                                                         
     449                 :     /**                                                                                                                                 
     450                 :      * Creates a Zend_Mime_Part attachment                                                                                              
     451                 :      *                                                                                                                                  
     452                 :      * Attachment is automatically added to the mail object after creation. The                                                         
     453                 :      * attachment object is returned to allow for further manipulation.                                                                 
     454                 :      *                                                                                                                                  
     455                 :      * @param  string         $body                                                                                                     
     456                 :      * @param  string         $mimeType                                                                                                 
     457                 :      * @param  string         $disposition                                                                                              
     458                 :      * @param  string         $encoding                                                                                                 
     459                 :      * @param  string         $filename OPTIONAL A filename for the attachment                                                          
     460                 :      * @return Zend_Mime_Part Newly created Zend_Mime_Part object (to allow                                                             
     461                 :      * advanced settings)                                                                                                               
     462                 :      */                                                                                                                                 
     463                 :     public function createAttachment($body,                                                                                             
     464                 :                                      $mimeType    = Zend_Mime::TYPE_OCTETSTREAM,                                                        
     465                 :                                      $disposition = Zend_Mime::DISPOSITION_ATTACHMENT,                                                  
     466                 :                                      $encoding    = Zend_Mime::ENCODING_BASE64,                                                         
     467                 :                                      $filename    = null)                                                                               
     468                 :     {                                                                                                                                   
     469                 :                                                                                                                                         
     470               4 :         $mp = new Zend_Mime_Part($body);                                                                                                
     471               4 :         $mp->encoding = $encoding;                                                                                                      
     472               4 :         $mp->type = $mimeType;                                                                                                          
     473               4 :         $mp->disposition = $disposition;                                                                                                
     474               4 :         $mp->filename = $filename;                                                                                                      
     475                 :                                                                                                                                         
     476               4 :         $this->addAttachment($mp);                                                                                                      
     477                 :                                                                                                                                         
     478               4 :         return $mp;                                                                                                                     
     479                 :     }                                                                                                                                   
     480                 :                                                                                                                                         
     481                 :     /**                                                                                                                                 
     482                 :      * Return a count of message parts                                                                                                  
     483                 :      *                                                                                                                                  
     484                 :      * @return integer                                                                                                                  
     485                 :      */                                                                                                                                 
     486                 :     public function getPartCount()                                                                                                      
     487                 :     {                                                                                                                                   
     488               4 :         return count($this->_parts);                                                                                                    
     489                 :     }                                                                                                                                   
     490                 :                                                                                                                                         
     491                 :     /**                                                                                                                                 
     492                 :      * Encode header fields                                                                                                             
     493                 :      *                                                                                                                                  
     494                 :      * Encodes header content according to RFC1522 if it contains non-printable                                                         
     495                 :      * characters.                                                                                                                      
     496                 :      *                                                                                                                                  
     497                 :      * @param  string $value                                                                                                            
     498                 :      * @return string                                                                                                                   
     499                 :      */                                                                                                                                 
     500                 :     protected function _encodeHeader($value)                                                                                            
     501                 :     {                                                                                                                                   
     502               4 :         if (Zend_Mime::isPrintable($value) === false) {                                                                                 
     503               0 :             if ($this->getHeaderEncoding() === Zend_Mime::ENCODING_QUOTEDPRINTABLE) {                                                   
     504               0 :                 $value = Zend_Mime::encodeQuotedPrintableHeader($value, $this->getCharset(), Zend_Mime::LINELENGTH, Zend_Mime::LINEEND);
     505               0 :             } else {                                                                                                                    
     506               0 :                 $value = Zend_Mime::encodeBase64Header($value, $this->getCharset(), Zend_Mime::LINELENGTH, Zend_Mime::LINEEND);         
     507                 :             }                                                                                                                           
     508               0 :         }                                                                                                                               
     509                 :                                                                                                                                         
     510               4 :         return $value;                                                                                                                  
     511                 :     }                                                                                                                                   
     512                 :                                                                                                                                         
     513                 :     /**                                                                                                                                 
     514                 :      * Add a header to the message                                                                                                      
     515                 :      *                                                                                                                                  
     516                 :      * Adds a header to this message. If append is true and the header already                                                          
     517                 :      * exists, raises a flag indicating that the header should be appended.                                                             
     518                 :      *                                                                                                                                  
     519                 :      * @param string  $headerName                                                                                                       
     520                 :      * @param string  $value                                                                                                            
     521                 :      * @param bool $append                                                                                                              
     522                 :      */                                                                                                                                 
     523                 :     protected function _storeHeader($headerName, $value, $append = false)                                                               
     524                 :     {                                                                                                                                   
     525               4 :         if (isset($this->_headers[$headerName])) {                                                                                      
     526               0 :             $this->_headers[$headerName][] = $value;                                                                                    
     527               0 :         } else {                                                                                                                        
     528               4 :             $this->_headers[$headerName] = array($value);                                                                               
     529                 :         }                                                                                                                               
     530                 :                                                                                                                                         
     531               4 :         if ($append) {                                                                                                                  
     532               4 :             $this->_headers[$headerName]['append'] = true;                                                                              
     533               4 :         }                                                                                                                               
     534                 :                                                                                                                                         
     535               4 :     }                                                                                                                                   
     536                 :                                                                                                                                         
     537                 :     /**                                                                                                                                 
     538                 :      * Clear header from the message                                                                                                    
     539                 :      *                                                                                                                                  
     540                 :      * @param string $headerName                                                                                                        
     541                 :      * @deprecated use public method directly                                                                                           
     542                 :      */                                                                                                                                 
     543                 :     protected function _clearHeader($headerName)                                                                                        
     544                 :     {                                                                                                                                   
     545               0 :         $this->clearHeader($headerName);                                                                                                
     546               0 :     }                                                                                                                                   
     547                 :                                                                                                                                         
     548                 :     /**                                                                                                                                 
     549                 :      * Helper function for adding a recipient and the corresponding header                                                              
     550                 :      *                                                                                                                                  
     551                 :      * @param string $headerName                                                                                                        
     552                 :      * @param string $email                                                                                                             
     553                 :      * @param string $name                                                                                                              
     554                 :      */                                                                                                                                 
     555                 :     protected function _addRecipientAndHeader($headerName, $email, $name)                                                               
     556                 :     {                                                                                                                                   
     557               4 :         $email = $this->_filterEmail($email);                                                                                           
     558               4 :         $name  = $this->_filterName($name);                                                                                             
     559                 :         // prevent duplicates                                                                                                           
     560               4 :         $this->_recipients[$email] = 1;                                                                                                 
     561               4 :         $this->_storeHeader($headerName, $this->_formatAddress($email, $name), true);                                                   
     562               4 :     }                                                                                                                                   
     563                 :                                                                                                                                         
     564                 :     /**                                                                                                                                 
     565                 :      * Adds To-header and recipient, $email can be an array, or a single string address                                                 
     566                 :      *                                                                                                                                  
     567                 :      * @param  string|array $email                                                                                                      
     568                 :      * @param  string $name                                                                                                             
     569                 :      * @return Zend_Mail Provides fluent interface                                                                                      
     570                 :      */                                                                                                                                 
     571                 :     public function addTo($email, $name='')                                                                                             
     572                 :     {                                                                                                                                   
     573               4 :         if (!is_array($email)) {                                                                                                        
     574               4 :             $email = array($name => $email);                                                                                            
     575               4 :         }                                                                                                                               
     576                 :                                                                                                                                         
     577               4 :         foreach ($email as $n => $recipient) {                                                                                          
     578               4 :             $this->_addRecipientAndHeader('To', $recipient, is_int($n) ? '' : $n);                                                      
     579               4 :             $this->_to[] = $recipient;                                                                                                  
     580               4 :         }                                                                                                                               
     581                 :                                                                                                                                         
     582               4 :         return $this;                                                                                                                   
     583                 :     }                                                                                                                                   
     584                 :                                                                                                                                         
     585                 :     /**                                                                                                                                 
     586                 :      * Adds Cc-header and recipient, $email can be an array, or a single string address                                                 
     587                 :      *                                                                                                                                  
     588                 :      * @param  string|array    $email                                                                                                   
     589                 :      * @param  string    $name                                                                                                          
     590                 :      * @return Zend_Mail Provides fluent interface                                                                                      
     591                 :      */                                                                                                                                 
     592                 :     public function addCc($email, $name='')                                                                                             
     593                 :     {                                                                                                                                   
     594               0 :         if (!is_array($email)) {                                                                                                        
     595               0 :             $email = array($name => $email);                                                                                            
     596               0 :         }                                                                                                                               
     597                 :                                                                                                                                         
     598               0 :         foreach ($email as $n => $recipient) {                                                                                          
     599               0 :             $this->_addRecipientAndHeader('Cc', $recipient, is_int($n) ? '' : $n);                                                      
     600               0 :         }                                                                                                                               
     601                 :                                                                                                                                         
     602               0 :         return $this;                                                                                                                   
     603                 :     }                                                                                                                                   
     604                 :                                                                                                                                         
     605                 :     /**                                                                                                                                 
     606                 :      * Adds Bcc recipient, $email can be an array, or a single string address                                                           
     607                 :      *                                                                                                                                  
     608                 :      * @param  string|array    $email                                                                                                   
     609                 :      * @return Zend_Mail Provides fluent interface                                                                                      
     610                 :      */                                                                                                                                 
     611                 :     public function addBcc($email)                                                                                                      
     612                 :     {                                                                                                                                   
     613               0 :         if (!is_array($email)) {                                                                                                        
     614               0 :             $email = array($email);                                                                                                     
     615               0 :         }                                                                                                                               
     616                 :                                                                                                                                         
     617               0 :         foreach ($email as $recipient) {                                                                                                
     618               0 :             $this->_addRecipientAndHeader('Bcc', $recipient, '');                                                                       
     619               0 :         }                                                                                                                               
     620                 :                                                                                                                                         
     621               0 :         return $this;                                                                                                                   
     622                 :     }                                                                                                                                   
     623                 :                                                                                                                                         
     624                 :     /**                                                                                                                                 
     625                 :      * Return list of recipient email addresses                                                                                         
     626                 :      *                                                                                                                                  
     627                 :      * @return array (of strings)                                                                                                       
     628                 :      */                                                                                                                                 
     629                 :     public function getRecipients()                                                                                                     
     630                 :     {                                                                                                                                   
     631               1 :         return array_keys($this->_recipients);                                                                                          
     632                 :     }                                                                                                                                   
     633                 :                                                                                                                                         
     634                 :     /**                                                                                                                                 
     635                 :      * Clear header from the message                                                                                                    
     636                 :      *                                                                                                                                  
     637                 :      * @param string $headerName                                                                                                        
     638                 :      * @return Zend_Mail Provides fluent inter                                                                                          
     639                 :      */                                                                                                                                 
     640                 :     public function clearHeader($headerName)                                                                                            
     641                 :     {                                                                                                                                   
     642               0 :         if (isset($this->_headers[$headerName])){                                                                                       
     643               0 :             unset($this->_headers[$headerName]);                                                                                        
     644               0 :         }                                                                                                                               
     645               0 :         return $this;                                                                                                                   
     646                 :     }                                                                                                                                   
     647                 :                                                                                                                                         
     648                 :     /**                                                                                                                                 
     649                 :      * Clears list of recipient email addresses                                                                                         
     650                 :      *                                                                                                                                  
     651                 :      * @return Zend_Mail Provides fluent interface                                                                                      
     652                 :      */                                                                                                                                 
     653                 :     public function clearRecipients()                                                                                                   
     654                 :     {                                                                                                                                   
     655               0 :         $this->_recipients = array();                                                                                                   
     656               0 :         $this->_to = array();                                                                                                           
     657                 :                                                                                                                                         
     658               0 :         $this->clearHeader('To');                                                                                                       
     659               0 :         $this->clearHeader('Cc');                                                                                                       
     660               0 :         $this->clearHeader('Bcc');                                                                                                      
     661                 :                                                                                                                                         
     662               0 :         return $this;                                                                                                                   
     663                 :     }                                                                                                                                   
     664                 :                                                                                                                                         
     665                 :     /**                                                                                                                                 
     666                 :      * Sets From-header and sender of the message                                                                                       
     667                 :      *                                                                                                                                  
     668                 :      * @param  string    $email                                                                                                         
     669                 :      * @param  string    $name                                                                                                          
     670                 :      * @return Zend_Mail Provides fluent interface                                                                                      
     671                 :      * @throws Zend_Mail_Exception if called subsequent times                                                                           
     672                 :      */                                                                                                                                 
     673                 :     public function setFrom($email, $name = null)                                                                                       
     674                 :     {                                                                                                                                   
     675               4 :         if (null !== $this->_from) {                                                                                                    
     676                 :             /**                                                                                                                         
     677                 :              * @see Zend_Mail_Exception                                                                                                 
     678                 :              */                                                                                                                         
     679                 :             #require_once 'Zend/Mail/Exception.php';                                                                                    
     680               0 :             throw new Zend_Mail_Exception('From Header set twice');                                                                     
     681                 :         }                                                                                                                               
     682                 :                                                                                                                                         
     683               4 :         $email = $this->_filterEmail($email);                                                                                           
     684               4 :         $name  = $this->_filterName($name);                                                                                             
     685               4 :         $this->_from = $email;                                                                                                          
     686               4 :         $this->_storeHeader('From', $this->_formatAddress($email, $name), true);                                                        
     687                 :                                                                                                                                         
     688               4 :         return $this;                                                                                                                   
     689                 :     }                                                                                                                                   
     690                 :                                                                                                                                         
     691                 :     /**                                                                                                                                 
     692                 :      * Set Reply-To Header                                                                                                              
     693                 :      *                                                                                                                                  
     694                 :      * @param string $email                                                                                                             
     695                 :      * @param string $name                                                                                                              
     696                 :      * @return Zend_Mail                                                                                                                
     697                 :      * @throws Zend_Mail_Exception if called more than one time                                                                         
     698                 :      */                                                                                                                                 
     699                 :     public function setReplyTo($email, $name = null)                                                                                    
     700                 :     {                                                                                                                                   
     701               1 :         if (null !== $this->_replyTo) {                                                                                                 
     702                 :             /**                                                                                                                         
     703                 :              * @see Zend_Mail_Exception                                                                                                 
     704                 :              */                                                                                                                         
     705                 :             #require_once 'Zend/Mail/Exception.php';                                                                                    
     706               0 :             throw new Zend_Mail_Exception('Reply-To Header set twice');                                                                 
     707                 :         }                                                                                                                               
     708                 :                                                                                                                                         
     709               1 :         $email = $this->_filterEmail($email);                                                                                           
     710               1 :         $name  = $this->_filterName($name);                                                                                             
     711               1 :         $this->_replyTo = $email;                                                                                                       
     712               1 :         $this->_storeHeader('Reply-To', $this->_formatAddress($email, $name), true);                                                    
     713                 :                                                                                                                                         
     714               1 :         return $this;                                                                                                                   
     715                 :     }                                                                                                                                   
     716                 :                                                                                                                                         
     717                 :     /**                                                                                                                                 
     718                 :      * Returns the sender of the mail                                                                                                   
     719                 :      *                                                                                                                                  
     720                 :      * @return string                                                                                                                   
     721                 :      */                                                                                                                                 
     722                 :     public function getFrom()                                                                                                           
     723                 :     {                                                                                                                                   
     724               1 :         return $this->_from;                                                                                                            
     725                 :     }                                                                                                                                   
     726                 :                                                                                                                                         
     727                 :     /**                                                                                                                                 
     728                 :      * Returns the current Reply-To address of the message                                                                              
     729                 :      *                                                                                                                                  
     730                 :      * @return string|null Reply-To address, null when not set                                                                          
     731                 :      */                                                                                                                                 
     732                 :     public function getReplyTo()                                                                                                        
     733                 :     {                                                                                                                                   
     734               1 :         return $this->_replyTo;                                                                                                         
     735                 :     }                                                                                                                                   
     736                 :                                                                                                                                         
     737                 :     /**                                                                                                                                 
     738                 :      * Clears the sender from the mail                                                                                                  
     739                 :      *                                                                                                                                  
     740                 :      * @return Zend_Mail Provides fluent interface                                                                                      
     741                 :      */                                                                                                                                 
     742                 :     public function clearFrom()                                                                                                         
     743                 :     {                                                                                                                                   
     744               0 :         $this->_from = null;                                                                                                            
     745               0 :         $this->clearHeader('From');                                                                                                     
     746                 :                                                                                                                                         
     747               0 :         return $this;                                                                                                                   
     748                 :     }                                                                                                                                   
     749                 :                                                                                                                                         
     750                 :      /**                                                                                                                                
     751                 :       * Clears the current Reply-To address from the message                                                                            
     752                 :       *                                                                                                                                 
     753                 :       * @return Zend_Mail Provides fluent interface                                                                                     
     754                 :       */                                                                                                                                
     755                 :     public function clearReplyTo()                                                                                                      
     756                 :     {                                                                                                                                   
     757               0 :         $this->_replyTo = null;                                                                                                         
     758               0 :         $this->clearHeader('Reply-To');                                                                                                 
     759                 :                                                                                                                                         
     760               0 :         return $this;                                                                                                                   
     761                 :     }                                                                                                                                   
     762                 :                                                                                                                                         
     763                 :     /**                                                                                                                                 
     764                 :      * Sets Default From-email and name of the message                                                                                  
     765                 :      *                                                                                                                                  
     766                 :      * @param  string               $email                                                                                              
     767                 :      * @param  string    Optional   $name                                                                                               
     768                 :      * @return void                                                                                                                     
     769                 :      */                                                                                                                                 
     770                 :     public static function setDefaultFrom($email, $name = null)                                                                         
     771                 :     {                                                                                                                                   
     772               0 :         self::$_defaultFrom = array('email' => $email, 'name' => $name);                                                                
     773               0 :     }                                                                                                                                   
     774                 :                                                                                                                                         
     775                 :     /**                                                                                                                                 
     776                 :      * Returns the default sender of the mail                                                                                           
     777                 :      *                                                                                                                                  
     778                 :      * @return null|array   Null if none was set.                                                                                       
     779                 :      */                                                                                                                                 
     780                 :     public static function getDefaultFrom()                                                                                             
     781                 :     {                                                                                                                                   
     782               0 :         return self::$_defaultFrom;                                                                                                     
     783                 :     }                                                                                                                                   
     784                 :                                                                                                                                         
     785                 :     /**                                                                                                                                 
     786                 :      * Clears the default sender from the mail                                                                                          
     787                 :      *                                                                                                                                  
     788                 :      * @return void                                                                                                                     
     789                 :      */                                                                                                                                 
     790                 :     public static function clearDefaultFrom()                                                                                           
     791                 :     {                                                                                                                                   
     792               0 :         self::$_defaultFrom = null;                                                                                                     
     793               0 :     }                                                                                                                                   
     794                 :                                                                                                                                         
     795                 :     /**                                                                                                                                 
     796                 :      * Sets From-name and -email based on the defaults                                                                                  
     797                 :      *                                                                                                                                  
     798                 :      * @return Zend_Mail Provides fluent interface                                                                                      
     799                 :      */                                                                                                                                 
     800                 :     public function setFromToDefaultFrom() {                                                                                            
     801               0 :         $from = self::getDefaultFrom();                                                                                                 
     802               0 :         if($from === null) {                                                                                                            
     803                 :             #require_once 'Zend/Mail/Exception.php';                                                                                    
     804               0 :             throw new Zend_Mail_Exception(                                                                                              
     805               0 :                 'No default From Address set to use');                                                                                  
     806                 :         }                                                                                                                               
     807                 :                                                                                                                                         
     808               0 :         $this->setFrom($from['email'], $from['name']);                                                                                  
     809                 :                                                                                                                                         
     810               0 :         return $this;                                                                                                                   
     811                 :     }                                                                                                                                   
     812                 :                                                                                                                                         
     813                 :     /**                                                                                                                                 
     814                 :      * Sets Default ReplyTo-address and -name of the message                                                                            
     815                 :      *                                                                                                                                  
     816                 :      * @param  string               $email                                                                                              
     817                 :      * @param  string    Optional   $name                                                                                               
     818                 :      * @return void                                                                                                                     
     819                 :      */                                                                                                                                 
     820                 :     public static function setDefaultReplyTo($email, $name = null)                                                                      
     821                 :     {                                                                                                                                   
     822               0 :         self::$_defaultReplyTo = array('email' => $email, 'name' => $name);                                                             
     823               0 :     }                                                                                                                                   
     824                 :                                                                                                                                         
     825                 :     /**                                                                                                                                 
     826                 :      * Returns the default Reply-To Address and Name of the mail                                                                        
     827                 :      *                                                                                                                                  
     828                 :      * @return null|array   Null if none was set.                                                                                       
     829                 :      */                                                                                                                                 
     830                 :     public static function getDefaultReplyTo()                                                                                          
     831                 :     {                                                                                                                                   
     832               1 :         return self::$_defaultReplyTo;                                                                                                  
     833                 :     }                                                                                                                                   
     834                 :                                                                                                                                         
     835                 :     /**                                                                                                                                 
     836                 :      * Clears the default ReplyTo-address and -name from the mail                                                                       
     837                 :      *                                                                                                                                  
     838                 :      * @return void                                                                                                                     
     839                 :      */                                                                                                                                 
     840                 :     public static function clearDefaultReplyTo()                                                                                        
     841                 :     {                                                                                                                                   
     842               0 :         self::$_defaultReplyTo = null;                                                                                                  
     843               0 :     }                                                                                                                                   
     844                 :                                                                                                                                         
     845                 :     /**                                                                                                                                 
     846                 :      * Sets ReplyTo-name and -email based on the defaults                                                                               
     847                 :      *                                                                                                                                  
     848                 :      * @return Zend_Mail Provides fluent interface                                                                                      
     849                 :      */                                                                                                                                 
     850                 :     public function setReplyToFromDefault() {                                                                                           
     851               0 :         $replyTo = self::getDefaultReplyTo();                                                                                           
     852               0 :         if($replyTo === null) {                                                                                                         
     853                 :             #require_once 'Zend/Mail/Exception.php';                                                                                    
     854               0 :             throw new Zend_Mail_Exception(                                                                                              
     855               0 :                 'No default Reply-To Address set to use');                                                                              
     856                 :         }                                                                                                                               
     857                 :                                                                                                                                         
     858               0 :         $this->setReplyTo($replyTo['email'], $replyTo['name']);                                                                         
     859                 :                                                                                                                                         
     860               0 :         return $this;                                                                                                                   
     861                 :     }                                                                                                                                   
     862                 :                                                                                                                                         
     863                 :     /**                                                                                                                                 
     864                 :      * Sets the Return-Path header of the message                                                                                       
     865                 :      *                                                                                                                                  
     866                 :      * @param  string    $email                                                                                                         
     867                 :      * @return Zend_Mail Provides fluent interface                                                                                      
     868                 :      * @throws Zend_Mail_Exception if set multiple times                                                                                
     869                 :      */                                                                                                                                 
     870                 :     public function setReturnPath($email)                                                                                               
     871                 :     {                                                                                                                                   
     872               0 :         if ($this->_returnPath === null) {                                                                                              
     873               0 :             $email = $this->_filterEmail($email);                                                                                       
     874               0 :             $this->_returnPath = $email;                                                                                                
     875               0 :             $this->_storeHeader('Return-Path', $email, false);                                                                          
     876               0 :         } else {                                                                                                                        
     877                 :             /**                                                                                                                         
     878                 :              * @see Zend_Mail_Exception                                                                                                 
     879                 :              */                                                                                                                         
     880                 :             #require_once 'Zend/Mail/Exception.php';                                                                                    
     881               0 :             throw new Zend_Mail_Exception('Return-Path Header set twice');                                                              
     882                 :         }                                                                                                                               
     883               0 :         return $this;                                                                                                                   
     884                 :     }                                                                                                                                   
     885                 :                                                                                                                                         
     886                 :     /**                                                                                                                                 
     887                 :      * Returns the current Return-Path address of the message                                                                           
     888                 :      *                                                                                                                                  
     889                 :      * If no Return-Path header is set, returns the value of {@link $_from}.                                                            
     890                 :      *                                                                                                                                  
     891                 :      * @return string                                                                                                                   
     892                 :      */                                                                                                                                 
     893                 :     public function getReturnPath()                                                                                                     
     894                 :     {                                                                                                                                   
     895               0 :         if (null !== $this->_returnPath) {                                                                                              
     896               0 :             return $this->_returnPath;                                                                                                  
     897                 :         }                                                                                                                               
     898                 :                                                                                                                                         
     899               0 :         return $this->_from;                                                                                                            
     900                 :     }                                                                                                                                   
     901                 :                                                                                                                                         
     902                 :     /**                                                                                                                                 
     903                 :      * Clears the current Return-Path address from the message                                                                          
     904                 :      *                                                                                                                                  
     905                 :      * @return Zend_Mail Provides fluent interface                                                                                      
     906                 :      */                                                                                                                                 
     907                 :     public function clearReturnPath()                                                                                                   
     908                 :     {                                                                                                                                   
     909               0 :         $this->_returnPath = null;                                                                                                      
     910               0 :         $this->clearHeader('Return-Path');                                                                                              
     911                 :                                                                                                                                         
     912               0 :         return $this;                                                                                                                   
     913                 :     }                                                                                                                                   
     914                 :                                                                                                                                         
     915                 :     /**                                                                                                                                 
     916                 :      * Sets the subject of the message                                                                                                  
     917                 :      *                                                                                                                                  
     918                 :      * @param   string    $subject                                                                                                      
     919                 :      * @return  Zend_Mail Provides fluent interface                                                                                     
     920                 :      * @throws  Zend_Mail_Exception                                                                                                     
     921                 :      */                                                                                                                                 
     922                 :     public function setSubject($subject)                                                                                                
     923                 :     {                                                                                                                                   
     924               4 :         if ($this->_subject === null) {                                                                                                 
     925               4 :             $subject = $this->_filterOther($subject);                                                                                   
     926               4 :             $this->_subject = $this->_encodeHeader($subject);                                                                           
     927               4 :             $this->_storeHeader('Subject', $this->_subject);                                                                            
     928               4 :         } else {                                                                                                                        
     929                 :             /**                                                                                                                         
     930                 :              * @see Zend_Mail_Exception                                                                                                 
     931                 :              */                                                                                                                         
     932                 :             #require_once 'Zend/Mail/Exception.php';                                                                                    
     933               0 :             throw new Zend_Mail_Exception('Subject set twice');                                                                         
     934                 :         }                                                                                                                               
     935               4 :         return $this;                                                                                                                   
     936                 :     }                                                                                                                                   
     937                 :                                                                                                                                         
     938                 :     /**                                                                                                                                 
     939                 :      * Returns the encoded subject of the message                                                                                       
     940                 :      *                                                                                                                                  
     941                 :      * @return string                                                                                                                   
     942                 :      */                                                                                                                                 
     943                 :     public function getSubject()                                                                                                        
     944                 :     {                                                                                                                                   
     945               0 :         return $this->_subject;                                                                                                         
     946                 :     }                                                                                                                                   
     947                 :                                                                                                                                         
     948                 :     /**                                                                                                                                 
     949                 :      * Clears the encoded subject from the message                                                                                      
     950                 :      *                                                                                                                                  
     951                 :      * @return  Zend_Mail Provides fluent interface                                                                                     
     952                 :      */                                                                                                                                 
     953                 :     public function clearSubject()                                                                                                      
     954                 :     {                                                                                                                                   
     955               0 :         $this->_subject = null;                                                                                                         
     956               0 :         $this->clearHeader('Subject');                                                                                                  
     957                 :                                                                                                                                         
     958               0 :         return $this;                                                                                                                   
     959                 :     }                                                                                                                                   
     960                 :                                                                                                                                         
     961                 :     /**                                                                                                                                 
     962                 :      * Sets Date-header                                                                                                                 
     963                 :      *                                                                                                                                  
     964                 :      * @param  timestamp|string|Zend_Date $date                                                                                         
     965                 :      * @return Zend_Mail Provides fluent interface                                                                                      
     966                 :      * @throws Zend_Mail_Exception if called subsequent times or wrong date format.                                                     
     967                 :      */                                                                                                                                 
     968                 :     public function setDate($date = null)                                                                                               
     969                 :     {                                                                                                                                   
     970               2 :         if ($this->_date === null) {                                                                                                    
     971               2 :             if ($date === null) {                                                                                                       
     972               2 :                 $date = date('r');                                                                                                      
     973               2 :             } else if (is_int($date)) {                                                                                                 
     974               0 :                 $date = date('r', $date);                                                                                               
     975               0 :             } else if (is_string($date)) {                                                                                              
     976               0 :                 $date = strtotime($date);                                                                                               
     977               0 :                 if ($date === false || $date < 0) {                                                                                     
     978                 :                     /**                                                                                                                 
     979                 :                      * @see Zend_Mail_Exception                                                                                         
     980                 :                      */                                                                                                                 
     981                 :                     #require_once 'Zend/Mail/Exception.php';                                                                            
     982               0 :                     throw new Zend_Mail_Exception('String representations of Date Header must be ' .                                    
     983               0 :                                                   'strtotime()-compatible');                                                            
     984                 :                 }                                                                                                                       
     985               0 :                 $date = date('r', $date);                                                                                               
     986               0 :             } else if ($date instanceof Zend_Date) {                                                                                    
     987               0 :                 $date = $date->get(Zend_Date::RFC_2822);                                                                                
     988               0 :             } else {                                                                                                                    
     989                 :                 /**                                                                                                                     
     990                 :                  * @see Zend_Mail_Exception                                                                                             
     991                 :                  */                                                                                                                     
     992                 :                 #require_once 'Zend/Mail/Exception.php';                                                                                
     993               0 :                 throw new Zend_Mail_Exception(__METHOD__ . ' only accepts UNIX timestamps, Zend_Date objects, ' .                       
     994               0 :                                               ' and strtotime()-compatible strings');                                                   
     995                 :             }                                                                                                                           
     996               2 :             $this->_date = $date;                                                                                                       
     997               2 :             $this->_storeHeader('Date', $date);                                                                                         
     998               2 :         } else {                                                                                                                        
     999                 :             /**                                                                                                                         
    1000                 :              * @see Zend_Mail_Exception                                                                                                 
    1001                 :              */                                                                                                                         
    1002                 :             #require_once 'Zend/Mail/Exception.php';                                                                                    
    1003               0 :             throw new Zend_Mail_Exception('Date Header set twice');                                                                     
    1004                 :         }                                                                                                                               
    1005               2 :         return $this;                                                                                                                   
    1006                 :     }                                                                                                                                   
    1007                 :                                                                                                                                         
    1008                 :     /**                                                                                                                                 
    1009                 :      * Returns the formatted date of the message                                                                                        
    1010                 :      *                                                                                                                                  
    1011                 :      * @return string                                                                                                                   
    1012                 :      */                                                                                                                                 
    1013                 :     public function getDate()                                                                                                           
    1014                 :     {                                                                                                                                   
    1015               1 :         return $this->_date;                                                                                                            
    1016                 :     }                                                                                                                                   
    1017                 :                                                                                                                                         
    1018                 :     /**                                                                                                                                 
    1019                 :      * Clears the formatted date from the message                                                                                       
    1020                 :      *                                                                                                                                  
    1021                 :      * @return Zend_Mail Provides fluent interface                                                                                      
    1022                 :      */                                                                                                                                 
    1023                 :     public function clearDate()                                                                                                         
    1024                 :     {                                                                                                                                   
    1025               0 :         $this->_date = null;                                                                                                            
    1026               0 :         $this->clearHeader('Date');                                                                                                     
    1027                 :                                                                                                                                         
    1028               0 :         return $this;                                                                                                                   
    1029                 :     }                                                                                                                                   
    1030                 :                                                                                                                                         
    1031                 :     /**                                                                                                                                 
    1032                 :      * Sets the Message-ID of the message                                                                                               
    1033                 :      *                                                                                                                                  
    1034                 :      * @param   boolean|string  $id                                                                                                     
    1035                 :      * true  :Auto                                                                                                                      
    1036                 :      * false :No set                                                                                                                    
    1037                 :      * null  :No set                                                                                                                    
    1038                 :      * string:Sets given string (Angle brackets is not necessary)                                                                       
    1039                 :      * @return  Zend_Mail Provides fluent interface                                                                                     
    1040                 :      * @throws  Zend_Mail_Exception                                                                                                     
    1041                 :      */                                                                                                                                 
    1042                 :     public function setMessageId($id = true)                                                                                            
    1043                 :     {                                                                                                                                   
    1044               0 :         if ($id === null || $id === false) {                                                                                            
    1045               0 :             return $this;                                                                                                               
    1046               0 :         } elseif ($id === true) {                                                                                                       
    1047               0 :             $id = $this->createMessageId();                                                                                             
    1048               0 :         }                                                                                                                               
    1049                 :                                                                                                                                         
    1050               0 :         if ($this->_messageId === null) {                                                                                               
    1051               0 :             $id = $this->_filterOther($id);                                                                                             
    1052               0 :             $this->_messageId = $id;                                                                                                    
    1053               0 :             $this->_storeHeader('Message-Id', '<' . $this->_messageId . '>');                                                           
    1054               0 :         } else {                                                                                                                        
    1055                 :             /**                                                                                                                         
    1056                 :              * @see Zend_Mail_Exception                                                                                                 
    1057                 :              */                                                                                                                         
    1058                 :             #require_once 'Zend/Mail/Exception.php';                                                                                    
    1059               0 :             throw new Zend_Mail_Exception('Message-ID set twice');                                                                      
    1060                 :         }                                                                                                                               
    1061                 :                                                                                                                                         
    1062               0 :         return $this;                                                                                                                   
    1063                 :     }                                                                                                                                   
    1064                 :                                                                                                                                         
    1065                 :     /**                                                                                                                                 
    1066                 :      * Returns the Message-ID of the message                                                                                            
    1067                 :      *                                                                                                                                  
    1068                 :      * @return string                                                                                                                   
    1069                 :      */                                                                                                                                 
    1070                 :     public function getMessageId()                                                                                                      
    1071                 :     {                                                                                                                                   
    1072               0 :         return $this->_messageId;                                                                                                       
    1073                 :     }                                                                                                                                   
    1074                 :                                                                                                                                         
    1075                 :                                                                                                                                         
    1076                 :     /**                                                                                                                                 
    1077                 :      * Clears the Message-ID from the message                                                                                           
    1078                 :      *                                                                                                                                  
    1079                 :      * @return Zend_Mail Provides fluent interface                                                                                      
    1080                 :      */                                                                                                                                 
    1081                 :     public function clearMessageId()                                                                                                    
    1082                 :     {                                                                                                                                   
    1083               0 :         $this->_messageId = null;                                                                                                       
    1084               0 :         $this->clearHeader('Message-Id');                                                                                               
    1085                 :                                                                                                                                         
    1086               0 :         return $this;                                                                                                                   
    1087                 :     }                                                                                                                                   
    1088                 :                                                                                                                                         
    1089                 :     /**                                                                                                                                 
    1090                 :      * Creates the Message-ID                                                                                                           
    1091                 :      *                                                                                                                                  
    1092                 :      * @return string                                                                                                                   
    1093                 :      */                                                                                                                                 
    1094                 :     public function createMessageId() {                                                                                                 
    1095                 :                                                                                                                                         
    1096               0 :         $time = time();                                                                                                                 
    1097                 :                                                                                                                                         
    1098               0 :         if ($this->_from !== null) {                                                                                                    
    1099               0 :             $user = $this->_from;                                                                                                       
    1100               0 :         } elseif (isset($_SERVER['REMOTE_ADDR'])) {                                                                                     
    1101               0 :             $user = $_SERVER['REMOTE_ADDR'];                                                                                            
    1102               0 :         } else {                                                                                                                        
    1103               0 :             $user = getmypid();                                                                                                         
    1104                 :         }                                                                                                                               
    1105                 :                                                                                                                                         
    1106               0 :         $rand = mt_rand();                                                                                                              
    1107                 :                                                                                                                                         
    1108               0 :         if ($this->_recipients !== array()) {                                                                                           
    1109               0 :             $recipient = array_rand($this->_recipients);                                                                                
    1110               0 :         } else {                                                                                                                        
    1111               0 :             $recipient = 'unknown';                                                                                                     
    1112                 :         }                                                                                                                               
    1113                 :                                                                                                                                         
    1114               0 :         if (isset($_SERVER["SERVER_NAME"])) {                                                                                           
    1115               0 :             $hostName = $_SERVER["SERVER_NAME"];                                                                                        
    1116               0 :         } else {                                                                                                                        
    1117               0 :             $hostName = php_uname('n');                                                                                                 
    1118                 :         }                                                                                                                               
    1119                 :                                                                                                                                         
    1120               0 :         return sha1($time . $user . $rand . $recipient) . '@' . $hostName;                                                              
    1121                 :     }                                                                                                                                   
    1122                 :                                                                                                                                         
    1123                 :     /**                                                                                                                                 
    1124                 :      * Add a custom header to the message                                                                                               
    1125                 :      *                                                                                                                                  
    1126                 :      * @param  string              $name                                                                                                
    1127                 :      * @param  string              $value                                                                                               
    1128                 :      * @param  boolean             $append                                                                                              
    1129                 :      * @return Zend_Mail           Provides fluent interface                                                                            
    1130                 :      * @throws Zend_Mail_Exception on attempts to create standard headers                                                               
    1131                 :      */                                                                                                                                 
    1132                 :     public function addHeader($name, $value, $append = false)                                                                           
    1133                 :     {                                                                                                                                   
    1134               0 :         $prohibit = array('to', 'cc', 'bcc', 'from', 'subject',                                                                         
    1135               0 :                           'reply-to', 'return-path',                                                                                    
    1136               0 :                           'date', 'message-id',                                                                                         
    1137               0 :                          );                                                                                                             
    1138               0 :         if (in_array(strtolower($name), $prohibit)) {                                                                                   
    1139                 :             /**                                                                                                                         
    1140                 :              * @see Zend_Mail_Exception                                                                                                 
    1141                 :              */                                                                                                                         
    1142                 :             #require_once 'Zend/Mail/Exception.php';                                                                                    
    1143               0 :             throw new Zend_Mail_Exception('Cannot set standard header from addHeader()');                                               
    1144                 :         }                                                                                                                               
    1145                 :                                                                                                                                         
    1146               0 :         $value = $this->_filterOther($value);                                                                                           
    1147               0 :         $value = $this->_encodeHeader($value);                                                                                          
    1148               0 :         $this->_storeHeader($name, $value, $append);                                                                                    
    1149                 :                                                                                                                                         
    1150               0 :         return $this;                                                                                                                   
    1151                 :     }                                                                                                                                   
    1152                 :                                                                                                                                         
    1153                 :     /**                                                                                                                                 
    1154                 :      * Return mail headers                                                                                                              
    1155                 :      *                                                                                                                                  
    1156                 :      * @return void                                                                                                                     
    1157                 :      */                                                                                                                                 
    1158                 :     public function getHeaders()                                                                                                        
    1159                 :     {                                                                                                                                   
    1160               0 :         return $this->_headers;                                                                                                         
    1161                 :     }                                                                                                                                   
    1162                 :                                                                                                                                         
    1163                 :     /**                                                                                                                                 
    1164                 :      * Sends this email using the given transport or a previously                                                                       
    1165                 :      * set DefaultTransport or the internal mail function if no                                                                         
    1166                 :      * default transport had been set.                                                                                                  
    1167                 :      *                                                                                                                                  
    1168                 :      * @param  Zend_Mail_Transport_Abstract $transport                                                                                  
    1169                 :      * @return Zend_Mail                    Provides fluent interface                                                                   
    1170                 :      */                                                                                                                                 
    1171                 :     public function send($transport = null)                                                                                             
    1172                 :     {                                                                                                                                   
    1173               2 :         if ($transport === null) {                                                                                                      
    1174               0 :             if (! self::$_defaultTransport instanceof Zend_Mail_Transport_Abstract) {                                                   
    1175                 :                 #require_once 'Zend/Mail/Transport/Sendmail.php';                                                                       
    1176               0 :                 $transport = new Zend_Mail_Transport_Sendmail();                                                                        
    1177               0 :             } else {                                                                                                                    
    1178               0 :                 $transport = self::$_defaultTransport;                                                                                  
    1179                 :             }                                                                                                                           
    1180               0 :         }                                                                                                                               
    1181                 :                                                                                                                                         
    1182               2 :         if ($this->_date === null) {                                                                                                    
    1183               1 :             $this->setDate();                                                                                                           
    1184               1 :         }                                                                                                                               
    1185                 :                                                                                                                                         
    1186               2 :         if(null === $this->_from && null !== self::getDefaultFrom()) {                                                                  
    1187               0 :             $this->setFromToDefaultFrom();                                                                                              
    1188               0 :         }                                                                                                                               
    1189                 :                                                                                                                                         
    1190               2 :         if(null === $this->_replyTo && null !== self::getDefaultReplyTo()) {                                                            
    1191               0 :             $this->setReplyToFromDefault();                                                                                             
    1192               0 :         }                                                                                                                               
    1193                 :                                                                                                                                         
    1194               2 :         $transport->send($this);                                                                                                        
    1195                 :                                                                                                                                         
    1196               2 :         return $this;                                                                                                                   
    1197                 :     }                                                                                                                                   
    1198                 :                                                                                                                                         
    1199                 :     /**                                                                                                                                 
    1200                 :      * Filter of email data                                                                                                             
    1201                 :      *                                                                                                                                  
    1202                 :      * @param string $email                                                                                                             
    1203                 :      * @return string                                                                                                                   
    1204                 :      */                                                                                                                                 
    1205                 :     protected function _filterEmail($email)                                                                                             
    1206                 :     {                                                                                                                                   
    1207               4 :         $rule = array("\r" => '',                                                                                                       
    1208               4 :                       "\n" => '',                                                                                                       
    1209               4 :                       "\t" => '',                                                                                                       
    1210               4 :                       '"'  => '',                                                                                                       
    1211               4 :                       ','  => '',                                                                                                       
    1212               4 :                       '<'  => '',                                                                                                       
    1213               4 :                       '>'  => '',                                                                                                       
    1214               4 :         );                                                                                                                              
    1215                 :                                                                                                                                         
    1216               4 :         return strtr($email, $rule);                                                                                                    
    1217                 :     }                                                                                                                                   
    1218                 :                                                                                                                                         
    1219                 :     /**                                                                                                                                 
    1220                 :      * Filter of name data                                                                                                              
    1221                 :      *                                                                                                                                  
    1222                 :      * @param string $name                                                                                                              
    1223                 :      * @return string                                                                                                                   
    1224                 :      */                                                                                                                                 
    1225                 :     protected function _filterName($name)                                                                                               
    1226                 :     {                                                                                                                                   
    1227               4 :         $rule = array("\r" => '',                                                                                                       
    1228               4 :                       "\n" => '',                                                                                                       
    1229               4 :                       "\t" => '',                                                                                                       
    1230               4 :                       '"'  => "'",                                                                                                      
    1231               4 :                       '<'  => '[',                                                                                                      
    1232               4 :                       '>'  => ']',                                                                                                      
    1233               4 :         );                                                                                                                              
    1234                 :                                                                                                                                         
    1235               4 :         return trim(strtr($name, $rule));                                                                                               
    1236                 :     }                                                                                                                                   
    1237                 :                                                                                                                                         
    1238                 :     /**                                                                                                                                 
    1239                 :      * Filter of other data                                                                                                             
    1240                 :      *                                                                                                                                  
    1241                 :      * @param string $data                                                                                                              
    1242                 :      * @return string                                                                                                                   
    1243                 :      */                                                                                                                                 
    1244                 :     protected function _filterOther($data)                                                                                              
    1245                 :     {                                                                                                                                   
    1246               4 :         $rule = array("\r" => '',                                                                                                       
    1247               4 :                       "\n" => '',                                                                                                       
    1248               4 :                       "\t" => '',                                                                                                       
    1249               4 :         );                                                                                                                              
    1250                 :                                                                                                                                         
    1251               4 :         return strtr($data, $rule);                                                                                                     
    1252                 :     }                                                                                                                                   
    1253                 :                                                                                                                                         
    1254                 :     /**                                                                                                                                 
    1255                 :      * Formats e-mail address                                                                                                           
    1256                 :      *                                                                                                                                  
    1257                 :      * @param string $email                                                                                                             
    1258                 :      * @param string $name                                                                                                              
    1259                 :      * @return string                                                                                                                   
    1260                 :      */                                                                                                                                 
    1261                 :     protected function _formatAddress($email, $name)                                                                                    
    1262                 :     {                                                                                                                                   
    1263               4 :         if ($name === '' || $name === null || $name === $email) {                                                                       
    1264               4 :             return $email;                                                                                                              
    1265                 :         } else {                                                                                                                        
    1266               1 :             $encodedName = $this->_encodeHeader($name);                                                                                 
    1267               1 :             if ($encodedName === $name &&                                                                                               
    1268               1 :                     ((strpos($name, '@') !== false) || (strpos($name, ',') !== false))) {                                               
    1269               0 :                 $format = '"%s" <%s>';                                                                                                  
    1270               0 :             } else {                                                                                                                    
    1271               1 :                 $format = '%s <%s>';                                                                                                    
    1272                 :             }                                                                                                                           
    1273               1 :             return sprintf($format, $encodedName, $email);                                                                              
    1274                 :         }                                                                                                                               
    1275                 :     }                                                                                                                                   
    1276                 :                                                                                                                                         
    1277                 : }                                                                                                                                       

Generated by PHP_CodeCoverage 1.0.4 using PHP 5.3.4 and PHPUnit 3.5.13 at Tue Jul 5 9:07:16 UTC 2011.