Changeset 946

Show
Ignore:
Timestamp:
07/23/08 20:41:17 (3 months ago)
Author:
bermiferrer
Message:

Composing messages via the AkMailComposer?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/action_mailer/lib/AkActionMailer.php

    r934 r946  
    2121require_once(AK_LIB_DIR.DS.'AkActionMailer'.DS.'AkMailParser.php'); 
    2222require_once(AK_LIB_DIR.DS.'AkActionMailer'.DS.'AkActionMailerQuoting.php'); 
     23require_once(AK_LIB_DIR.DS.'AkActionMailer'.DS.'AkMailComposer.php'); 
    2324 
    2425ak_define('MAIL_EMBED_IMAGES_AUTOMATICALLY_ON_EMAILS', false); 
     
    276277    var $helpers = array('mail'); 
    277278    var $Message; 
     279    var $Composer; 
    278280    var $_defaultMailDriverName = 'AkMailMessage'; 
    279281 
     
    538540        $Message->send(); 
    539541    } 
     542     
     543    function getRawMessage() 
     544    { 
     545        if(empty($this->Message->_has_been_created_by_mailer)){ 
     546            trigger_error(Ak::t('You need to create() a message before getting it as raw text.'),E_USER_ERROR); 
     547            return false; 
     548        } 
     549        $Composer =& $this->getComposer(); 
     550        return $Composer->getRawMessage(); 
     551    } 
    540552 
    541553 
     
    546558    function &create($method_name, $parameters, $content_type = '') 
    547559    { 
    548         require_once(AK_LIB_DIR.DS.'AkActionMailer'.DS.'AkMailComposer.php'); 
    549         $Composer =& new AkMailComposer(); 
    550         $Composer->init($this); 
     560        $Composer =& $this->getComposer(); 
    551561        $args = func_get_args(); 
    552         call_user_func_array(array($Composer, 'build'), $args); 
     562        call_user_func_array(array(&$Composer, 'build'), $args); 
     563        $this->Message->_has_been_created_by_mailer = true; 
    553564        return $this->Message; 
    554565    } 
     
    572583            $this->{"perform".ucfirst(strtolower($this->delivery_method))."Delivery"}($this->Message); 
    573584        } 
     585        $this->Message->_has_been_delivered_by_mailer = true; 
    574586        return $this->Message; 
    575587    } 
     
    588600        $settings = array_merge($default_settings, $settings); 
    589601 
    590         return $this->_deliverUsingMailDeliveryMethod('SMTP', $Message, $settings); 
     602        return $this->_deliverUsingMailDeliveryMethod('Smtp', $Message, $settings); 
    591603 
    592604    } 
     
    594606    function performPhpDelivery(&$Message, $settings = array()) 
    595607    { 
    596         return $this->_deliverUsingMailDeliveryMethod('PHPMail', $Message, $settings); 
     608        return $this->_deliverUsingMailDeliveryMethod('PhpMail', $Message, $settings); 
    597609    } 
    598610 
     
    657669    } 
    658670 
    659      
     671    function &getComposer() 
     672    { 
     673        if(empty($this->Composer)){ 
     674            $this->setComposer(); 
     675        } 
     676        return $this->Composer; 
     677    } 
     678 
     679    function setComposer($Composer = null) 
     680    { 
     681        if(!empty($Composer)){ 
     682            $this->Composer = $Composer; 
     683        }else{ 
     684            $this->Composer =& new AkMailComposer(); 
     685            $this->Composer->init($this); 
     686        } 
     687    } 
     688 
     689 
    660690    /** 
    661691     * Alias for getModelName 
     
    715745        return $helpers; 
    716746    } 
    717      
     747 
    718748    function _deliverUsingMailDeliveryMethod($method, &$Message, $options) 
    719749    { 
     
    729759        } 
    730760        $DeliveryHandler = new $handler_name(); 
    731         return $DeliveryHandler->deliver($Message, $options); 
    732     } 
    733  
    734     /** 
    735      * Returns a raw version  
    736      * 
    737      */ 
    738     function getRawMessage() 
    739     { 
    740         return $this->Message->getRawMessage(); 
    741     } 
     761        $this->Message =& $Message; 
     762        return $DeliveryHandler->deliver($this, $options); 
     763    } 
     764 
     765 
    742766 
    743767} 
  • branches/action_mailer/lib/AkActionMailer/AkMailBase.php

    r934 r946  
    5151            $this->body = stristr($content_type,'text/') ? str_replace(array("\r\n","\r"),"\n", $body) : $body; 
    5252            if($content_type == 'text/html'){ 
    53                 AkMailParser::extractImagesIntoInlineParts($this); 
     53                $Parser = new AkMailParser(); 
     54                $Parser->extractImagesIntoInlineParts($this); 
    5455            } 
    5556        }else{ 
     
    157158        foreach ((array)$Mail as $field => $value){ 
    158159            if(!empty($value) && is_string($value)){ 
    159                 if(strtolower(get_class($Mail)) == 'akmailmessage' && $field=='body'){ 
     160                if($Mail->isMainMessage() && $field=='body'){ 
    160161                    $result .= $value."\n"; 
    161162                }elseif(empty($Mail->data) && $field=='body'){ 
     
    176177            } 
    177178        } 
     179 
    178180        return $result; 
    179181    } 
    180182 
    181     function _getAttributesForHeader($header_index) 
    182     { 
    183         $header_index = strtolower(AkInflector::underscore($header_index)).'_attributes'; 
    184         if(!empty($this->$header_index)){ 
    185             $attributes = ''; 
     183    function isMainMessage() 
     184    { 
     185        return strtolower(get_class($this)) == 'akmailmessage'; 
     186    } 
     187 
     188    function isPart() 
     189    { 
     190        return strtolower(get_class($this)) == 'akmailpart'; 
     191    } 
     192 
     193    function _getAttributesForHeader($header_index, $force_reload = false) 
     194    { 
     195        if(empty($this->_header_attributes_set_for[$header_index]) || $force_reload){ 
     196            $header_index = strtolower(AkInflector::underscore($header_index)).'_attributes'; 
    186197            if(!empty($this->$header_index)){ 
    187                 foreach ((array)$this->$header_index as $key=>$value){ 
    188                     $attributes .= ";$key=$value"; 
     198                $attributes = ''; 
     199                if(!empty($this->$header_index)){ 
     200                    foreach ((array)$this->$header_index as $key=>$value){ 
     201                        $attributes .= ";$key=$value"; 
     202                    } 
    189203                } 
    190             } 
    191             return $attributes; 
     204                $this->_header_attributes_set_for[$header_index] = $attributes; 
     205            } 
     206        } 
     207         
     208        if (!empty($this->_header_attributes_set_for[$header_index])){ 
     209            return $this->_header_attributes_set_for[$header_index]; 
    192210        } 
    193211    } 
     
    273291    } 
    274292 
    275     function _getHeadersAsText() 
    276     { 
    277         if(empty($this->_headers_as_text)){ 
    278             $headers = $this->getHeaders(true); 
    279             unset($headers['Charset']); 
    280             $this->_headers_as_text = array_pop($this->prepareHeaders($headers)); 
    281         } 
    282         return $this->_headers_as_text; 
     293    function getRawHeaders() 
     294    { 
     295        if(empty($this->raw_headers)){ 
     296            $this->headers = $this->getHeaders(true); 
     297            if($this->isPart()){ 
     298                $this->prepareHeadersForRendering(); 
     299            } 
     300            unset($this->headers['Charset']); 
     301            $this->raw_headers = array_pop($this->prepareHeaders($this->headers)); 
     302        } 
     303        return $this->raw_headers; 
    283304    } 
    284305 
     
    287308        if(empty($this->headers) || $force_reload){ 
    288309            $this->loadHeaders(); 
     310            $this->_addHeaderAttributes(); 
    289311        } 
    290312        return $this->headers; 
     
    299321    function loadHeaders() 
    300322    { 
    301         if(empty($this->date) && empty($this->_skip_adding_date_to_headers)){ 
     323        if(empty($this->date) && $this->isMainMessage()){ 
    302324            $this->setDate(); 
    303325        } 
     
    532554    } 
    533555 
     556    function hasParts() 
     557    { 
     558        return !empty($this->parts); 
     559    } 
     560 
    534561    function hasNonAttachmentParts() 
    535562    { 
     
    557584        $options = array_merge($options, is_string($arg_options) ? array('body'=>$arg_options) : (array)$arg_options); 
    558585        $options = array_merge(array('content_disposition' => 'attachment', 'content_transfer_encoding' => 'base64'), $options); 
     586 
    559587        $this->setPart($options); 
    560588    } 
     
    587615    function getEncoded() 
    588616    { 
    589         return $this->_getHeadersAsText().AK_ACTION_MAILER_EOL.AK_ACTION_MAILER_EOL.$this->getBody(); 
     617        return $this->getRawHeaders().AK_ACTION_MAILER_EOL.AK_ACTION_MAILER_EOL.$this->getBody(); 
    590618    } 
    591619 
  • branches/action_mailer/lib/AkActionMailer/AkMailComposer.php

    r934 r946  
    77    var $ActionMailer; 
    88    var $parts = array(); 
    9     var $composed_message = ''; 
    10  
    11      
     9    var $raw_message = ''; 
     10    var $composed_message = array(); 
     11    var $_boundary_stack = array(); 
     12    var $boundary = ''; 
     13 
     14 
    1215    function init(&$ActionMailer) 
    1316    { 
     
    1518        $this->Message =& $ActionMailer->Message; 
    1619    } 
    17      
     20 
    1821    function build() 
    1922    { 
     
    3437        } 
    3538    } 
    36      
     39 
    3740 
    3841    function _prepareInlineBodyParts($message_content_type = 'multipart/alternative') 
     
    141144 
    142145 
    143      
    144      
    145      
    146  
    147     /* 
    148  
    149     function create($Mailer, $method_name, $parameters, $content_type) 
    150     { 
    151         $args = func_get_args(); 
    152          
    153         $this->_initializeDefaults($method_name); 
    154         if(method_exists($this, $method_name)){ 
    155             call_user_func_array(array(&$this, $method_name), $args); 
     146 
     147 
     148 
     149    function getRawMessage($MessageOrPart = null, $force_overload = false) 
     150    { 
     151        $Message = empty($MessageOrPart) ? $this->Message : $MessageOrPart; 
     152        if($force_overload || empty($Message->raw_message)){ 
     153            list($raw_headers, $raw_body) = $this->getRawHeadersAndBody($Message); 
     154            $Message->raw_message = $raw_headers. 
     155            AK_ACTION_MAILER_EOL.AK_ACTION_MAILER_EOL. 
     156            $raw_body; 
     157        } 
     158        return $Message->raw_message; 
     159    } 
     160 
     161 
     162 
     163    function getRawHeadersAndBody($MessageOrPart = null) 
     164    { 
     165        $Message = empty($MessageOrPart) ? $this->Message : $MessageOrPart; 
     166        $raw_body_or_parts = $this->getRawBodyOrRawParts($Message); 
     167 
     168        if(is_array($raw_body_or_parts)){ 
     169            $raw_body = ''; 
     170            $this->openMultipartBlock(); 
     171 
     172            $Message->content_type_attributes['boundary'] = $this->getBoundary(); 
     173            $Message->_skip_adding_date_to_headers = !$Message->isMainMessage(); 
     174             
     175            /* 
     176            if($Message->isMainMessage()){ 
     177                $Message->setContentType('multipart/mixed'); 
     178            } 
     179            */ 
     180 
     181            $raw_headers = $Message->getRawHeaders(); 
     182            foreach ($raw_body_or_parts as $raw_part_headers=>$raw_part_body){ 
     183                $raw_body .= 
     184                AK_ACTION_MAILER_EOL. 
     185                AK_ACTION_MAILER_EOL. 
     186                '--'. 
     187                $this->getBoundary(). 
     188                AK_ACTION_MAILER_EOL. 
     189                $raw_part_headers. 
     190                AK_ACTION_MAILER_EOL. 
     191                AK_ACTION_MAILER_EOL. 
     192                $raw_part_body; 
     193            } 
     194            $raw_body .= AK_ACTION_MAILER_EOL.'--'.$this->getBoundary().'--'.AK_ACTION_MAILER_EOL; 
     195 
     196            $this->closeMultipartBlock(); 
    156197        }else{ 
    157             trigger_error(Ak::t('Could not find the method %method on the model %model', array('%method'=>$method_name, '%model'=>$this->getModelName())), E_USER_ERROR); 
    158         } 
    159         $parameters = @array_shift($args); 
    160  
    161         $Mail =& $this->_MailDriver; 
    162  
    163         $this->_prepareInlineBodyParts($Mail); 
    164  
    165         $Mail->setMimeVersion((empty($Mail->mime_version) && !empty($Mail->parts)) ? '1.0' : $Mail->mime_version); 
    166  
    167         $this->Mail =& $Mail; 
    168         return $Mail; 
    169     } 
     198            $raw_headers = $Message->getRawHeaders(); 
     199            $raw_body = $raw_body_or_parts; 
     200        } 
     201 
     202        return array($raw_headers, $raw_body); 
     203    } 
     204 
     205 
     206    function getRawBodyOrRawParts($MessageOrPart = null) 
     207    { 
     208        $Message = empty($MessageOrPart) ? $this->Message : $MessageOrPart; 
     209        $body = $Message->getBody(); 
     210        if(empty($body) && $Message->hasParts()){ 
     211            $result = array(); 
     212            foreach (array_keys($Message->parts) as $k){ 
     213                $Part = $Message->parts[$k]; 
     214                list($raw_headers, $raw_body) = $this->getRawHeadersAndBody($Part); 
     215                $result[$raw_headers] = $raw_body; 
     216            } 
     217            return $result; 
     218        } 
     219        return $body; 
     220    } 
     221 
     222    function openMultipartBlock() 
     223    { 
     224        $this->setBoundary($this->getBoundaryString()); 
     225    } 
     226 
     227    function closeMultipartBlock() 
     228    { 
     229        $this->latest_closed_boundary = array_pop($this->_boundary_stack); 
     230    } 
     231 
     232 
     233    function setBoundary($boundary) 
     234    { 
     235        $this->boundary = $boundary; 
     236        array_push($this->_boundary_stack, $boundary); 
     237        return $this->boundary; 
     238    } 
     239 
     240    function getBoundary() 
     241    { 
     242        return $this->boundary; 
     243    } 
     244 
     245 
     246    function getBoundaryString() 
     247    { 
     248        return md5(Ak::randomString(10).time()); 
     249    } 
     250 
     251 
     252 
     253 
     254 
     255 
     256 
    170257 
    171258    function compose(&$Mail) 
     
    196283    } 
    197284 
     285 
     286    /* 
     287 
     288    function create($Mailer, $method_name, $parameters, $content_type) 
     289    { 
     290    $args = func_get_args(); 
     291 
     292    $this->_initializeDefaults($method_name); 
     293    if(method_exists($this, $method_name)){ 
     294    call_user_func_array(array(&$this, $method_name), $args); 
     295    }else{ 
     296    trigger_error(Ak::t('Could not find the method %method on the model %model', array('%method'=>$method_name, '%model'=>$this->getModelName())), E_USER_ERROR); 
     297    } 
     298    $parameters = @array_shift($args); 
     299 
     300    $Mail =& $this->_MailDriver; 
     301 
     302    $this->_prepareInlineBodyParts($Mail); 
     303 
     304    $Mail->setMimeVersion((empty($Mail->mime_version) && !empty($Mail->parts)) ? '1.0' : $Mail->mime_version); 
     305 
     306    $this->Mail =& $Mail; 
     307    return $Mail; 
     308    } 
     309 
     310 
    198311    function composePart($Part) 
    199312    { 
    200         return $this->compose($Part); 
     313    return $this->compose($Part); 
    201314    } 
    202315 
     
    205318    function getMultipartMessage() 
    206319    { 
    207         $raw_message = ''; 
    208         $boundary = $this->getBoundary(); 
    209  
    210         $this->content_type_attributes['boundary'] = $boundary; 
    211         $this->_skip_adding_date_to_headers = true; 
    212         $raw_message .= $this->getRawHeaders(); 
    213  
    214         foreach (array_keys($this->parts) as $k){ 
    215             $raw_message .= AK_ACTION_MAILER_EOL.AK_ACTION_MAILER_EOL.'--'.$boundary.AK_ACTION_MAILER_EOL.$this->parts[$k]->getRawMessage(); 
    216         } 
    217  
    218         $raw_message .= AK_ACTION_MAILER_EOL.'--'.$boundary.'--'.AK_ACTION_MAILER_EOL; 
    219  
    220     } 
    221  
    222     function getBoundary() 
    223     { 
    224         return 'mimepart_'.Ak::randomString(8).'..'.Ak::randomString(8); 
    225     } 
    226  
    227     function getRawPart() 
    228     { 
    229         return $this->getRawHeaders().AK_ACTION_MAILER_EOL.AK_ACTION_MAILER_EOL.$this->getRawBody(); 
    230     } 
    231  
    232     function getRawHeaders($Mail) 
    233     { 
    234         $Mail->_addHeaderAttributes(); 
    235         return $Mail->_getHeadersAsText(); 
    236     } 
    237      
     320    $raw_message = ''; 
     321    $boundary = $this->getBoundary(); 
     322 
     323    $this->content_type_attributes['boundary'] = $boundary; 
     324    $this->_skip_adding_date_to_headers = true; 
     325    $raw_message .= $this->getRawHeaders(); 
     326 
     327    foreach (array_keys($this->parts) as $k){ 
     328    $raw_message .= AK_ACTION_MAILER_EOL.AK_ACTION_MAILER_EOL.'--'.$boundary.AK_ACTION_MAILER_EOL.$this->parts[$k]->getRawMessage(); 
     329    } 
     330 
     331    $raw_message .= AK_ACTION_MAILER_EOL.'--'.$boundary.'--'.AK_ACTION_MAILER_EOL; 
     332 
     333    } 
     334 
     335 
     336 
    238337    */ 
    239338 
  • branches/action_mailer/lib/AkActionMailer/AkMailDelivery/AkPhpMailDelivery.php

    r934 r946  
    44class AkPhpMailDelivery extends AkObject 
    55{ 
    6     function deliver(&$Message, $settings = array()) 
     6    function deliver(&$Mailer, $settings = array()) 
    77    { 
     8        $Message =& $Mailer->Message; 
    89        return mail($Message->getTo(), $Message->getSubject(), $Message->bodyToString(), $Message->_getHeadersAsText()); 
    910    } 
  • branches/action_mailer/lib/AkActionMailer/AkMailDelivery/AkSmtpDelivery.php

    r934 r946  
    44class AkSmtpDelivery extends AkObject 
    55{ 
    6     function deliver(&$Message, $settings = array()) 
     6    function deliver(&$Mailer, $settings = array()) 
    77    { 
     8        $Message =& $Mailer->Message; 
     9         
    810        $SmtpClient =& Mail::factory('smtp', $settings); 
    911 
     
    4749        } 
    4850 
    49         if (PEAR::isError($smtp->data($Message->getRawMessage()))) { 
     51        if (PEAR::isError($smtp->data($Mailer->getRawMessage()))) { 
    5052            return PEAR::raiseError('unable to send data'); 
    5153        } 
  • branches/action_mailer/lib/AkActionMailer/AkMailDelivery/AkTestDelivery.php

    r934 r946  
    44class AkTestDelivery extends AkObject 
    55{ 
    6     function deliver(&$Message, $settings = array()) 
     6    function deliver(&$Mailer, $settings = array()) 
    77    { 
    8         $settings['ActionMailer']->deliveries[] =& $Message->getEncoded(); 
     8        $settings['ActionMailer']->deliveries[] =& $Mailer->Message->getEncoded(); 
    99    } 
    1010} 
  • branches/action_mailer/lib/AkActionMailer/AkMailMessage.php

    r934 r946  
    122122        return AkActionMailerQuoting::quoteIfNecessary($this->subject, $charset); 
    123123    } 
    124  
     124     
    125125    function _getMessageHeaderFieldFormated($address_header_field) 
    126126    { 
     
    128128        return join(", ",AkActionMailerQuoting::quoteAnyAddressIfNecessary(Ak::toArray($address_header_field), $charset)); 
    129129    } 
     130     
     131 
     132    function getRawMessage() 
     133    { 
     134        return AkMailComposer::getRawMessage($this); 
     135    } 
    130136} 
    131137 
  • branches/action_mailer/lib/AkActionMailer/AkMailPart.php

    r915 r946  
    55 
    66     
    7     function _prepareHeadersForRendering() 
     7    function prepareHeadersForRendering() 
    88    { 
    99        $this->_removeUnnecesaryHeaders(); 
    10         $this->_addHeaderAttributes(); 
    1110    } 
    1211 
  • branches/action_mailer/test/fixtures/app/models/test_mailer.php

    r934 r946  
    324324        )); 
    325325    } 
    326      
    327     function alternative_message_from_templates() 
    328     { 
    329          
    330     }  
     326 
     327    function alternative_message_from_templates($recipient, $include_logo = false) 
     328    { 
     329        $this->set(array( 
     330        'recipients' => $recipient, 
     331        'subject' => "Alternative message from template", 
     332        'from' => "some.one@example.com", 
     333        'body' => array('include_logo' => $include_logo) 
     334        )); 
     335    } 
    331336 
    332337    function &receive($raw_email) 
  • branches/action_mailer/test/fixtures/app/views/test_mailer/alternative_message_from_templates.text.html.tpl

    r934 r946  
    66<p>Akelos framework Logo</p> 
    77 
     8{?include_logo} 
     9<img src="/images/akelos_framework_logo.png" /> 
     10{end} 
    811<hidden> 
    912<img src="http://www.bermilabs.com/images/bermilabs_logo.png" /> 
    10  
    11 <img src="/images/akelos_framework_logo.png" /> 
    1213</hidden> 
    1314 
  • branches/action_mailer/test/unit/lib/AkActionMailer.php

    r934 r946  
    181181    } 
    182182 
    183      
    184      
    185     /**
     183 
     184 
     185    /**
    186186    function test_nested_parts() 
    187187    { 
     
    189189        $Created = $TestMailer->create('nested_multipart', $this->recipient); 
    190190 
    191          
     191 
    192192        $this->assertEqual(2, count($Created->parts)); 
    193193        $this->assertEqual(2, count($Created->parts[0]->parts)); 
     
    197197        $this->assertEqual( "akmailpart", strtolower(get_class($Created->parts[0]->parts[0]))); 
    198198        $this->assertEqual( "text/plain", $Created->parts[0]->parts[0]->content_type ); 
    199          
     199 
    200200        $this->assertEqual( "text/html", $Created->parts[0]->parts[1]->content_type ); 
    201201        $this->assertEqual( "application/octet-stream", $Created->parts[1]->content_type ); 
    202202 
    203          
     203 
    204204        return; 
    205205        $TestMailer =& new TestMailer(); 
     
    211211        $this->assertEqual('test.txt', $Attachment->original_filename); 
    212212        $this->assertEqual('test abcdefghijklmnopqstuvwxyz', $Attachment->body); 
    213          
     213 
    214214        $this->assertEqual(trim($Mail->bodyToString()), "test text\nline #2\n\n<b>test</b> HTML<br/>\nline #2\n\n\nAttachment: test.txt"); 
    215          
    216          
     215 
     216 
    217217    } 
    218218 
     
    238238        $this->assertTrue($Created = $TestMailer->create('signed_up', $this->recipient)); 
    239239        $this->assertEqual($Expected->getEncoded(), $Created->getEncoded()); 
    240          
     240 
    241241        $this->assertTrue($TestMailer->deliver('signed_up', $this->recipient)); 
    242242        $this->assertTrue(!empty($TestMailer->deliveries[0])); 
    243243        $this->assertEqual($Expected->getEncoded(), $TestMailer->deliveries[0]); 
    244          
    245     } 
    246  
    247      
     244 
     245    } 
     246 
     247 
    248248    function test_custom_template() 
    249249    { 
     
    257257        $this->assertTrue($Created = $TestMailer->create('custom_template', $this->recipient)); 
    258258        $this->assertEqual($Expected->getEncoded(), $Created->getEncoded()); 
    259          
     259 
    260260    } 
    261261 
     
    325325        $this->assertTrue(!empty($TestMailer->deliveries[0])); 
    326326        $this->assertEqual($Expected->getEncoded(), $TestMailer->deliveries[0]); 
    327          
     327 
    328328        $this->assertEqual($Created->getSubject(), '=?ISO-8859-1?Q?testing_is=F8_charsets?='); 
    329          
     329 
    330330    } 
    331331 
     
    351351        $this->assertTrue(!empty($TestMailer->deliveries[0])); 
    352352        $this->assertEqual($Expected->getEncoded(), $TestMailer->deliveries[0]); 
    353      
     353 
    354354        $this->assertEqual($Created->getSubject(), 'testing unencoded subject'); 
    355355    } 
    356356 
    357      
     357 
    358358    function test_perform_deliveries_flag() 
    359359    { 
     
    369369 
    370370    } 
    371    
     371 
    372372 
    373373    function test_unquote_quoted_printable_subject() 
     
    624624    } 
    625625 
    626      
     626 
    627627    function test_implicitly_multipart_messages() 
    628628    { 
     
    736736        $this->assertTrue(!empty($Mail->from)); 
    737737    } 
    738      
     738 
     739 
     740    function _test_should_encode_alternative_message_from_templates() 
     741    { 
     742        $TestMailer =& new TestMailer(); 
     743        $Message = $TestMailer->create('alternative_message_from_templates', $this->recipient); 
     744        $rendered_message = $TestMailer->getRawMessage(); 
     745 
     746        $this->assertPattern(   '/Content-Type: multipart\/alternative;charset=UTF-8;boundary=[a-f0-9]{32}\r\n'. 
     747        'Mime-Version: 1.0\r\n'. 
     748        'Subject:/', $rendered_message); 
     749        $this->assertPattern('/To:/', $rendered_message); 
     750        $this->assertPattern('/Date:/', $rendered_message); 
     751        $this->assertPattern('/--[a-f0-9]{32}\r\nContent-Type: text\/plain;charset=UTF-8\r\nContent-Disposition: inline/', $rendered_message); 
     752        $this->assertPattern('/--[a-f0-9]{32}\r\nContent-Type: text\/html;charset=UTF-8\r\nContent-Disposition: inline/', $rendered_message); 
     753        $this->assertPattern('/--[a-f0-9]{32}--/', $rendered_message); 
     754    } 
     755*/ 
     756    function test_should_encode_alternative_message_from_templates_with_embeded_images() 
     757    { 
     758        $TestMailer =& new TestMailer(); 
     759        $Message = $TestMailer->create('alternative_message_from_templates', $this->recipient, true); 
     760 
     761        $TestMailer->delivery_method = 'smtp'; 
     762 
     763        $TestMailer->deliver($Message); 
     764 
     765        $rendered_message = $TestMailer->getRawMessage(); 
     766         
     767        echo $rendered_message; 
     768        return ; 
     769 
     770        $this->assertPattern(   '/Content-Type: multipart\/alternative;charset=UTF-8;boundary=[a-f0-9]{32}\r\n'. 
     771        'Mime-Version: 1.0\r\n'. 
     772        'Subject:/', $rendered_message); 
     773        $this->assertPattern('/To:/', $rendered_message); 
     774        $this->assertPattern('/Date:/', $rendered_message); 
     775        $this->assertPattern('/Content-Type: multipart\/alternative;charset=UTF-8/', $rendered_message); 
     776        $this->assertPattern('/--[a-f0-9]{32}\r\nContent-Type: text\/plain;charset=UTF-8\r\nContent-Disposition: inline/', $rendered_message); 
     777        $this->assertPattern('/--[a-f0-9]{32}\r\nContent-Type: text\/html;charset=UTF-8\r\nContent-Disposition: inline/', $rendered_message); 
     778        $this->assertPattern('/--[a-f0-9]{32}--/', $rendered_message); 
     779 
     780 
     781    } 
     782 
    739783    /**/ 
    740784} 
    741785 
    742 Ak::test('Tests_for_Mailers'); 
     786//Ak::test('Tests_for_Mailers'); 
    743787Ak::test('Tests_for_AkActionMailer'); 
    744788 
  • branches/action_mailer/test/unit/lib/AkActionMailer/AkMailEncoder.php

    r934 r946  
    2323        $TestMailer =& new TestMailer(); 
    2424        $Delivered = $TestMailer->deliver('alternative_message_from_templates', $this->recipient); 
    25         $MailComposer = new AkMailComposer($Delivered); 
    26          
     25        
    2726        echo $MailComposer->compose($Delivered); 
    2827    }