Changeset 915

Show
Ignore:
Timestamp:
07/21/08 18:36:52 (3 months ago)
Author:
bermiferrer
Message:

Refactoring the monolithic AkMail? object into

AkMailMessage? (contains message headers, simple body, and parts)
AkMailPart? (message parts)
AkMailBase? (common functionality for messages and parts)
AkMailHeader? (for message and part headers - not implemented yet)
AkMailComposer? (multipart and nested message composer)

Right now the nested message composing ( Multipart( text + html ) + Attachment ) is not supported unless parts are set manually using

set(
'parts' => array('...')
)

We need to make it work in this scenario:

signup()

renders automatically

signup.text.plain.tpl
signup.text.html.tpl

and using setAttachment() we need to be able to add attachments, wrapping previous inline message into a multipart/alternative part and changing AkMailMessage? content type to multipart/mixed

Files:

Legend:

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

    r887 r915  
    1818 
    1919require_once(AK_LIB_DIR.DS.'AkBaseModel.php'); 
    20 require_once(AK_LIB_DIR.DS.'AkActionMailer'.DS.'AkMail.php'); 
     20require_once(AK_LIB_DIR.DS.'AkActionMailer'.DS.'AkMailMessage.php'); 
    2121require_once(AK_LIB_DIR.DS.'AkActionMailer'.DS.'AkMailParser.php'); 
    2222require_once(AK_LIB_DIR.DS.'AkActionMailer'.DS.'AkActionMailerQuoting.php'); 
     
    276276    var $helpers = array('mail'); 
    277277    var $_MailDriver; 
    278     var $_defaultMailDriverName = 'AkMail'; 
     278    var $_defaultMailDriverName = 'AkMailMessage'; 
    279279 
    280280    function __construct($Driver = null) 
     
    456456    { 
    457457        $args = func_get_args(); 
    458         print_r($args); 
    459458        return call_user_func_array(array(&$this->_MailDriver, 'setAttachment'), $args); 
    460459    } 
     
    468467     * This simplifies creating mail objects from datasources. 
    469468     *  
    470      * If the methos does not exists the parameter will be added to the body. 
     469     * If the method does not exists the parameter will be added to the body. 
    471470     */ 
    472471    function set($attributes = array()) 
     
    476475            unset($attributes['template']); 
    477476        } 
     477 
     478        if((!empty($attributes['attachment']) || !empty($attributes['attachments'])) && 
     479        (empty($attributes['parts']) && empty($attributes['part']) && empty($attributes['body']))){ 
     480            // we can render here the body if there are attachments 
     481        } 
     482 
    478483        $this->_MailDriver->set($attributes); 
    479484    } 
     485 
    480486 
    481487    /** 
     
    514520    function receive($raw_mail) 
    515521    { 
    516         $this->_MailDriver =& AkMail::parse($raw_mail); 
     522        $this->_MailDriver =& AkMailBase::parse($raw_mail); 
    517523        return $this->_MailDriver; 
    518524    } 
     
    529535    function deliverDirectly(&$Mail) 
    530536    { 
    531         $Mail =& new AkMail($Mail); 
     537        $Mail =& new $this->_defaultMailDriverName ($Mail); 
    532538        $Mail->send(); 
    533539    } 
     
    536542    /** 
    537543     * Initialize the mailer via the given +method_name+. The body will be 
    538      * rendered and a new AkMail object created. 
     544     * rendered and a new AkMailMessage object created. 
    539545     */ 
    540546    function &create($method_name, $parameters, $content_type = '') 
     
    549555        } 
    550556        $parameters = @array_shift($args); 
    551         $content_type = @array_shift($args); 
    552557 
    553558        $Mail =& $this->_MailDriver; 
     559 
     560        $this->_prepareInlineBodyParts($Mail); 
     561 
     562        $Mail->setMimeVersion((empty($Mail->mime_version) && !empty($Mail->parts)) ? '1.0' : $Mail->mime_version); 
     563 
     564        $this->Mail =& $Mail; 
     565        return $Mail; 
     566    } 
     567 
     568    function _prepareInlineBodyParts(&$Mail, $mail_content_type = 'multipart/alternative') 
     569    { 
    554570 
    555571        if(!is_string($Mail->body)){ 
     
    557573                $Mail->_avoid_multipart_propagation = true; 
    558574                $templates = $this->_getAvailableTemplates(); 
     575                $alternative_multiparts = array(); 
    559576                foreach ($templates as $template_name){ 
    560577                    if(preg_match('/^([^\.]+)\.([^\.]+\.[^\.]+)\.(tpl)$/',$template_name, $match)){ 
    561578                        if($this->template == $match[1]){ 
    562579                            $content_type = str_replace('.','/', $match[2]); 
    563                             $Mail->setPart(array( 
     580 
     581                            $current_part = array( 
    564582                            'content_type' => $content_type, 
    565583                            'disposition' => 'inline', 
    566584                            'charset' => @$Mail->charset, 
    567                             'body' => $this->renderMessage($this->getTemplatePath().DS.$template_name, $Mail->body))); 
     585                            'body' => $this->renderMessage($this->getTemplatePath().DS.$template_name, $Mail->body)); 
     586 
     587                            $Mail->setPart($current_part); 
    568588                        } 
    569589                    } 
    570590                } 
     591 
    571592                if(!empty($Mail->parts)){ 
    572                     $Mail->content_type = 'multipart/alternative'
     593                    $Mail->content_type = $mail_content_type
    573594                    $Mail->parts = $Mail->getSortedParts($Mail->parts, $Mail->implicit_parts_order); 
    574595                } 
     
    595616            } 
    596617        } 
    597  
    598         $Mail->setMimeVersion((empty($Mail->mime_version) && !empty($Mail->parts)) ? '1.0' : $Mail->mime_version); 
    599  
    600         $this->Mail =& $Mail; 
    601         return $Mail; 
    602618    } 
    603619 
     
    612628 
    613629    /** 
    614     * Delivers an AkMail object. By default, it delivers the cached mail 
     630    * Delivers an AkMailMessage object. By default, it delivers the cached mail 
    615631    * object (from the AkActionMailer::create method). If no cached mail object exists, and 
    616632    * no alternate has been given as the parameter, this will fail. 
     
    700716    function performTestDelivery(&$Mail) 
    701717    { 
    702         //$this->performSmtpDelivery($Mail); return ; 
     718        //$this->performSmtpDelivery($Mail); 
    703719        $this->deliveries[] =& $Mail->getEncoded(); 
    704720    } 
  • branches/action_mailer/lib/AkActionMailer/AkActionMailerQuoting.php

    r887 r915  
    4949             
    5050            $line = preg_replace($search_pattern, 'sprintf( "=%02X", ord ( "$0" ) ) ;', $line ); 
    51             $length = utf8_strlen($line); 
     51            $length = strlen($line); 
    5252             
    5353            $last_char = ord($line[$length-1]); 
  • branches/action_mailer/lib/AkActionMailer/AkMailEncoder.php

    r887 r915  
    11<?php 
    22 
    3 class AkMailEncoder extends Mail_mimeEncode 
     3class AkMailEncoder extends AkObject 
    44{ 
    55 
    66 
     7     
     8     
     9     
    710    function setMimeContents($options = array()) 
    811    { 
  • branches/action_mailer/lib/AkActionMailer/AkMailParser.php

    r824 r915  
    3232    } 
    3333 
    34     function parse($raw_message = '', $options = array()
     34    function parse($raw_message = '', $options = array(), $object_type = 'AkMailMessage'
    3535    { 
    3636        $parser_class = empty($options['parser_class']) ? 'AkMailParser' : $options['parser_class']; 
    3737        $Parser =& new $parser_class($options); 
    38         $Mail = new stdClass(); 
     38        $Mail = new $object_type(); 
    3939        $raw_message = empty($raw_message) ? $Parser->raw_message : $raw_message; 
    4040        if(!empty($raw_message)){ 
     
    9090                return false; 
    9191            }else{ 
    92                 $Part = $Parser->parse($raw_part); 
     92                $Part = $Parser->parse($raw_part, array(), 'AkMailPart'); 
    9393            } 
    9494            $this->parts[] = $Part; 
     
    228228                $header['encoded'] = $header['value']; 
    229229                $header['value'] = $header_value; 
     230                isset($charset) && $header['charset'] = $charset; 
    230231            } 
    231232        } 
     
    281282    } 
    282283 
     284     
     285    function importStructure(&$MailOrPart, $structure = array()) 
     286    { 
     287        if(isset($structure['header'])){ 
     288            $structure['headers'] = $structure['header']; 
     289            unset($structure['header']); 
     290        } 
     291        foreach ($structure as $attribute=>$value){ 
     292            if($attribute[0] != '_'){ 
     293                $attribute_setter = 'set'.AkInflector::camelize($attribute); 
     294                if(method_exists($MailOrPart, $attribute_setter)){ 
     295                    $MailOrPart->$attribute_setter($value); 
     296                }else{ 
     297                    $MailOrPart->{AkInflector::underscore($attribute)} = $value; 
     298                } 
     299            } 
     300        } 
     301        return ; 
     302    } 
     303     
     304     
     305    function extractImagesIntoInlineParts(&$Mail, $options = array()) 
     306    { 
     307        $html =& $Mail->body; 
     308        require_once(AK_LIB_DIR.DS.'AkActionView'.DS.'helpers'.DS.'text_helper.php'); 
     309        $images = TextHelper::get_image_urls_from_html($html); 
     310        $html_images = array(); 
     311        if(!empty($images)){ 
     312            require_once(AK_LIB_DIR.DS.'AkImage.php'); 
     313            require_once(AK_LIB_DIR.DS.'AkActionView'.DS.'helpers'.DS.'asset_tag_helper.php'); 
     314 
     315            $images = array_diff(array_unique($images), array('')); 
     316 
     317            foreach ($images as $image){ 
     318                $original_image_name = $image; 
     319                $image = $this->_getImagePath($image); 
     320                if(!empty($image)){ 
     321                    $extenssion = substr($image, strrpos('.'.$image,'.')); 
     322                    $image_name = Ak::uuid().'.'.$extenssion; 
     323                    $html_images[$original_image_name] = 'cid:'.$image_name; 
     324 
     325                    $Mail->setAttachment('image/'.$extenssion, array( 
     326                    'body' => Ak::file_get_contents($image), 
     327                    'filename' => $image_name, 
     328                    'content_disposition' => 'inline', 
     329                    'content_id' => '<'.$image_name.'>', 
     330                    )); 
     331                } 
     332            } 
     333            $modified_html = str_replace(array_keys($html_images),array_values($html_images), $html); 
     334            if($modified_html != $html){ 
     335                $html = $modified_html; 
     336                $Mail->_moveBodyToInlinePart(false); 
     337            } 
     338        } 
     339    } 
     340     
     341    function _getImagePath($path) 
     342    { 
     343        if(preg_match('/^http(s)?:\/\//', $path)){ 
     344            $path_info = pathinfo($path); 
     345            $base_file_name = Ak::sanitize_include($path_info['basename'], 'paranaoid'); 
     346            if(empty($path_info['extension'])){ // no extension, we don't do magic stuff 
     347                $path = ''; 
     348            }else{ 
     349                $local_path = AK_TMP_DIR.DS.'mailer'.DS.'remote_images'.DS.md5($base_file_name['dirname']).DS.$base_file_name.'.'.$path_info['extension']; 
     350                if(!file_exists($local_path) || (time() > @filemtime($local_path)+7200)){ 
     351                    if(!Ak::file_put_contents($local_path, Ak::url_get_contents($path))){ 
     352                        return ''; 
     353                    } 
     354                } 
     355                return $local_path; 
     356            } 
     357        } 
     358 
     359        $path = AK_PUBLIC_DIR.Ak::sanitize_include($path); 
     360 
     361        if(!file_exists($path)){ 
     362            $path = ''; 
     363        } 
     364        return $path; 
     365    } 
     366 
    283367} 
    284368 
  • branches/action_mailer/test/fixtures/app/models/test_mailer.php

    r887 r915  
    44{ 
    55    var $delivery_method = 'test'; 
    6      
     6 
    77    function signed_up($recipient) 
    88    { 
     
    7878        'bcc' => "Grytøyr <stian3@example.com>", 
    7979        'body' => "Nothing to see here.", 
    80         'charset' => "ISO-8859-1"  
     80        'charset' => "ISO-8859-1" 
    8181        )); 
    8282    } 
     
    119119        'subject' => "Foo áëô îü", 
    120120        'from' => "test@example.com", 
    121         'charset' => "utf-8", 
     121        'charset' => "UTF-8", 
    122122        'parts' => array( 
    123123        array('content_type' => 'text/plain', 'body' => 'blah'), 
     
    234234 
    235235        'parts' => array( 
    236             array('content_type' => 'multipart/alternative', 'content_disposition' => 'inline',  'headers' => array("Foo" => "bar"), 'parts' => array( 
    237                      array('content_type' => 'text/plain', 'body' => 'test text\nline #2'), 
    238                     array('content_type' => 'text/html', 'body' => '<b>test</b> HTML<br/>\nline #2') 
    239                 ) 
    240             ), 
     236        array( 
     237        'content_type' => 'multipart/alternative', 
     238        'content_disposition' => 'inline', 
     239        'headers' => array("Foo" => "bar"), 
     240        'parts' => array( 
     241        array('content_type' => 'text/plain', 'body' => "test text\nline #2"), 
     242        array('content_type' => 'text/html', 'body' => "<b>test</b> HTML<br/>\nline #2") 
     243        ) 
    241244        ), 
    242          
     245        ), 
     246 
    243247        'attachment' => array( 
    244             'content_type' => 'application/octet-stream','filename' => 'test.txt', 'body' => "test abcdefghijklmnopqstuvwxyz" 
     248        'content_type' => 'application/octet-stream','filename' => 'test.txt', 'body' => "test abcdefghijklmnopqstuvwxyz" 
    245249        ) 
    246250        )); 
     
    256260 
    257261        'part' => array('content_type' => 'text/html', 'body' => 'yo'), 
    258          
     262 
    259263        'attachment' => array( 
    260             'content_type' => 'image/jpeg','filename' => 'test.jpeg', 'body' => "i am not a real picture", 'headers' => array('Content-ID' => '<test@test.com>') 
    261         ) 
    262         )); 
    263     } 
    264      
     264        'content_type' => 'image/jpeg','filename' => 'test.jpeg', 'body' => "i am not a real picture", 'headers' => array('Content-ID' => '<test@test.com>') 
     265        ) 
     266        )); 
     267    } 
     268 
    265269    function unnamed_attachment($recipient) 
    266270    { 
     
    272276 
    273277        'part' => array('content_type' => 'text/plain', 'body' => 'hullo'), 
    274          
     278 
    275279        'attachment' => array( 
    276             'content_type' => 'application/octet-stream','body' => "test abcdefghijklmnopqstuvwxyz" 
     280        'content_type' => 'application/octet-stream','body' => "test abcdefghijklmnopqstuvwxyz" 
    277281        ) 
    278282        )); 
     
    290294    } 
    291295 
    292      
     296 
    293297    function custom_content_type_attributes() 
    294298    { 
     
    308312        'recipients' => "bermi@bermilabs.com", 
    309313        'subject' => "Multipart rendering", 
    310         'from' => "testing@bermilabs.com" 
    311         )); 
    312          
    313          
    314         $this->addAttachment('audio/mp3', array( 
    315         'body'=>file_get_contents(AK_BASE_DIR.DS.'test/fixtures/data/action_mailer/testing.mp3') 
    316         )); 
    317          
     314        'from' => "testing@bermilabs.com", 
     315        'attachment' => array('content_type' => 'audio/mp3', 'filename' => 'test.mp3', 'body' => file_get_contents(AK_BASE_DIR.DS.'test/fixtures/data/action_mailer/testing.mp3')), 
     316        )); 
     317 
    318318        return ; 
     319 
    319320        $this->set(array( 
    320321        'recipients' => "no.one@example.com", 
     
    323324        )); 
    324325    } 
    325      
     326 
    326327    function &receive($raw_email) 
    327328    { 
  • branches/action_mailer/test/fixtures/app/views/test_mailer/multipart_rendering.text.html.tpl

    r887 r915  
    88<hidden> 
    99<img src="http://www.bermilabs.com/images/bermilabs_logo.png" /> 
     10 
    1011<img src="/images/akelos_framework_logo.png" /> 
    1112</hidden> 
  • branches/action_mailer/test/unit/lib/AkActionMailer.php

    r887 r915  
    9797        $headers = array( 
    9898        "Subject: =?ISO-8859-1?Q?=C9ste_es_el_sof=E1_del_q_habl=E9_=5B?=\n\r =?ISO-8859-1?Q?Fwd=3A_Sof=E1=2E=5D_?="=>'Subject: Éste es el sofá del q hablé [Fwd: Sofá.]', 
    99         
     99 
    100100        "Subject: =?ISO-8859-1?Q?=C9ste_es_el_sof=E1_del_q_habl=E9_=5B?==?ISO-8859-1?Q?Fwd=3A_Sof=E1=2E=5D_?="=>'Subject: Éste es el sofá del q hablé [Fwd: Sofá.]', 
    101         
     101 
    102102        'Subject: =?UTF-8?B?UHLDvGZ1bmcgUHLDvGZ1bmc=?='=>'Subject: Prüfung Prüfung', 
    103103        'Subject: =?iso-8859-1?Q?RV:_=5BFwd:__chiste_inform=E1tico=5D?='=>'Subject: RV: [Fwd:  chiste informático]', 
     
    106106        'X-Akelos-Random: =?UTF-8?B?ZXN0w6Egw6MgYsOkc8OqNjQ=?='=>'X-Akelos-Random: está ã bäsê64', 
    107107        //'X-Akelos-Random: =?ISO-2022-JP?B?GyRCJDMkcyRLJEEkT0AkMyYbKEI=?='=>'X-Akelos-Random: こんにちは世界', 
    108         
     108 
    109109        'X-Akelos-Random: =?UTF-8?Q?E=C3=B1e_de_Espa=C3=B1a?= =?UTF-8?Q?_Fwd:_?= =?UTF-8?Q?=E3=81=93=E3=82=93=E3=81=AB=E3=81=A1=E3=81=AF=E4=B8=96=E7=95=8C?='=>'X-Akelos-Random: Eñe de España Fwd: こんにちは世界', 
    110110        'From: =?ISO-8859-1?Q?Crist=F3bal_G=F3mez_Moreno?= <cristobal@example.com>'=>'From: Cristóbal Gómez Moreno <cristobal@example.com>', 
    111         
     111 
    112112        "Subject: =?ISO-8859-1?Q?=C9ste_es_el_sof=E1_del_q_habl=E9_=5B?=\n =?ISO-8859-1?Q?Fwd=3A_Sof=E1=2E=5D_?="=>'Subject: Éste es el sofá del q hablé [Fwd: Sofá.]' 
    113113        ); 
     
    124124    function test_email_quoted_with_0d0a() 
    125125    { 
    126         $Mail = AkMail::parse(file_get_contents(AK_TEST_DIR.'/fixtures/data/action_mailer/raw_email_quoted_with_0d0a')); 
     126        $Mail = AkMailBase::parse(file_get_contents(AK_TEST_DIR.'/fixtures/data/action_mailer/raw_email_quoted_with_0d0a')); 
    127127        $this->assertPattern('/Elapsed time/', $Mail->body); 
    128128    } 
     
    130130    function test_email_with_partially_quoted_subject() 
    131131    { 
    132         $Mail = AkMail::parse(file_get_contents(AK_TEST_DIR.'/fixtures/data/action_mailer/raw_email_with_partially_quoted_subject')); 
     132        $Mail = AkMailBase::parse(file_get_contents(AK_TEST_DIR.'/fixtures/data/action_mailer/raw_email_with_partially_quoted_subject')); 
    133133        $this->assertEqual("Re: Test: \"\346\274\242\345\255\227\" mid \"\346\274\242\345\255\227\" tail", $Mail->subject); 
    134134    } 
     
    136136    /**/ 
    137137} 
     138 
     139 
     140 
     141 
     142 
     143 
     144 
     145 
     146 
     147 
     148 
     149 
     150 
     151 
     152 
     153 
     154 
    138155 
    139156 
     
    147164    function new_mail($charset = 'utf-8') 
    148165    { 
    149         $Mail =& new AkMail(); 
     166        $Mail =& new AkMailMessage(); 
    150167        $Mail->setMimeVersion('1.0'); 
    151168        $Mail->setContentType('text/plain; charset:'.$charset); 
     
    157174    { 
    158175        $this->Mailer =& new AkActionMailer(); 
    159         //$this->Mailer->delivery_method = 'test'; 
     176        $this->Mailer->delivery_method = 'test'; 
    160177        $this->Mailer->perform_deliveries = true; 
    161178        $this->Mailer->deliveries = array(); 
    162         //$this->recipient = 'test@localhost'; 
    163     } 
    164  
    165     /* 
     179        $this->recipient = 'test@localhost'; 
     180        $this->recipient = 'bermi@bermilabs.com'; 
     181    } 
     182 
     183    function __test_multipart_rendering() 
     184    { 
     185 
     186        $TestMailer =& new TestMailer(); 
     187        $Delivered = $TestMailer->deliver('multipart_rendering', $this->recipient); 
     188        echo $Delivered->getRawMessage(); 
     189         
     190        return ; 
     191        $ReceivingTestMailer =& new TestMailer(); 
     192        $Mail =& $ReceivingTestMailer->receive($Delivered->getRawMessage()); 
     193        $Attachment = Ak::first($Mail->attachments); 
     194        $this->assertEqual('test.txt', $Attachment->original_filename); 
     195        $this->assertEqual('test abcdefghijklmnopqstuvwxyz', $Attachment->body); 
     196         
     197        $this->assertEqual(trim($Mail->bodyToString()), "test text\nline #2\n\n<b>test</b> HTML<br/>\nline #2\n\n\nAttachment: test.txt"); 
     198         
     199         
     200         
     201    } 
     202     
     203     
     204    /**/ 
    166205    function test_nested_parts() 
    167206    { 
    168         $HelperMailer =& new TestMailer(); 
    169         $Created = $HelperMailer->create('nested_multipart', $this->recipient); 
    170  
     207        $TestMailer =& new TestMailer(); 
     208        $Created = $TestMailer->create('nested_multipart', $this->recipient); 
     209 
     210         
    171211        $this->assertEqual(2, count($Created->parts)); 
    172212        $this->assertEqual(2, count($Created->parts[0]->parts)); 
    173213        $this->assertEqual( "multipart/mixed", $Created->content_type); 
    174214        $this->assertEqual( "multipart/alternative", $Created->parts[0]->content_type ); 
    175         $this->assertEqual( "bar", $Created->parts[0]->header['Foo'] ); 
     215        $this->assertEqual( "bar", $Created->parts[0]->getHeader('Foo') ); 
     216        $this->assertEqual( "akmailpart", strtolower(get_class($Created->parts[0]->parts[0]))); 
    176217        $this->assertEqual( "text/plain", $Created->parts[0]->parts[0]->content_type ); 
     218         
    177219        $this->assertEqual( "text/html", $Created->parts[0]->parts[1]->content_type ); 
    178220        $this->assertEqual( "application/octet-stream", $Created->parts[1]->content_type ); 
    179     } 
    180  
     221 
     222         
     223        return; 
     224        $TestMailer =& new TestMailer(); 
     225        $Delivered = $TestMailer->deliver('nested_multipart', $this->recipient); 
     226 
     227        $ReceivingTestMailer =& new TestMailer(); 
     228        $Mail =& $ReceivingTestMailer->receive($Delivered->getRawMessage()); 
     229        $Attachment = Ak::first($Mail->attachments); 
     230        $this->assertEqual('test.txt', $Attachment->original_filename); 
     231        $this->assertEqual('test abcdefghijklmnopqstuvwxyz', $Attachment->body); 
     232         
     233        $this->assertEqual(trim($Mail->bodyToString()), "test text\nline #2\n\n<b>test</b> HTML<br/>\nline #2\n\n\nAttachment: test.txt"); 
     234         
     235         
     236    } 
    181237 
    182238    function test_attachment_with_custom_header() 
    183239    { 
    184         $HelperMailer =& new TestMailer(); 
    185         $Created = $HelperMailer->create('attachment_with_custom_header', $this->recipient); 
    186         $this->assertEqual( "<test@test.com>", $Created->parts[1]->header['Content-ID']); 
    187     } 
     240        $TestMailer =& new TestMailer(); 
     241        $Created = $TestMailer->create('attachment_with_custom_header', $this->recipient); 
     242        $this->assertEqual( "<test@test.com>", $Created->parts[1]->getHeader('Content-ID')); 
     243    } 
     244 
    188245 
    189246    function test_signed_up() 
     
    200257        $this->assertTrue($Created = $TestMailer->create('signed_up', $this->recipient)); 
    201258        $this->assertEqual($Expected->getEncoded(), $Created->getEncoded()); 
     259         
    202260        $this->assertTrue($TestMailer->deliver('signed_up', $this->recipient)); 
    203261        $this->assertTrue(!empty($TestMailer->deliveries[0])); 
    204262        $this->assertEqual($Expected->getEncoded(), $TestMailer->deliveries[0]); 
    205     } 
    206  
     263         
     264    } 
     265 
     266     
    207267    function test_custom_template() 
    208268    { 
     
    216276        $this->assertTrue($Created = $TestMailer->create('custom_template', $this->recipient)); 
    217277        $this->assertEqual($Expected->getEncoded(), $Created->getEncoded()); 
     278         
    218279    } 
    219280 
     
    259320        $this->assertEqual($Expected->getEncoded(), $TestMailer->deliveries[0]); 
    260321    } 
    261  
    262322 
    263323 
     
    284344        $this->assertTrue(!empty($TestMailer->deliveries[0])); 
    285345        $this->assertEqual($Expected->getEncoded(), $TestMailer->deliveries[0]); 
    286     } 
    287  
     346         
     347        $this->assertEqual($Created->getSubject(), '=?ISO-8859-1?Q?testing_is=F8_charsets?='); 
     348         
     349    } 
    288350 
    289351 
     
    308370        $this->assertTrue(!empty($TestMailer->deliveries[0])); 
    309371        $this->assertEqual($Expected->getEncoded(), $TestMailer->deliveries[0]); 
    310     } 
    311  
    312  
     372     
     373        $this->assertEqual($Created->getSubject(), 'testing unencoded subject'); 
     374    } 
     375 
     376     
    313377    function test_perform_deliveries_flag() 
    314378    { 
     
    324388 
    325389    } 
     390   
    326391 
    327392    function test_unquote_quoted_printable_subject() 
     
    335400EOF; 
    336401 
    337         $Mail = AkMail::parse($msg); 
     402        $Mail = AkMailBase::parse($msg); 
    338403        $this->assertEqual("testing testing \326\244", $Mail->subject); 
    339         $this->assertEqual("=?UTF-8?Q?testing_testing_=D6=A4?=", $Mail->getSubject()); 
    340  
    341     } 
     404        $this->assertEqual("=?UTF-8?Q?testing_testing_=D6=A4?=", $Mail->getSubject('UTF-8')); 
     405 
     406    } 
     407 
    342408 
    343409    function test_unquote_7bit_subject() 
     
    351417EOF; 
    352418 
    353         $Mail = AkMail::parse($msg); 
     419        $Mail = AkMailBase::parse($msg); 
    354420        $this->assertEqual("this == working?", $Mail->subject); 
    355421        $this->assertEqual("this == working?", $Mail->getSubject()); 
     
    369435EOF; 
    370436 
    371         $Mail = AkMail::parse($msg); 
     437        $Mail = AkMailBase::parse($msg); 
    372438        $this->assertEqual("The=3Dbody", $Mail->body); 
    373439        $this->assertEqual("The=3Dbody", $Mail->getBody()); 
     
    386452EOF; 
    387453 
    388         $Mail = AkMail::parse($msg); 
     454        $Mail = AkMailBase::parse($msg); 
    389455        $this->assertEqual("The=body", $Mail->body); 
    390456        $this->assertEqual("The=3Dbody", $Mail->getBody()); 
     
    403469EOF; 
    404470 
    405         $Mail = AkMail::parse($msg); 
     471        $Mail = AkMailBase::parse($msg); 
    406472        $this->assertEqual("The body", $Mail->body); 
    407473        $this->assertEqual("VGhlIGJvZHk=", $Mail->getBody()); 
     
    446512        $TestMailer =& new TestMailer(); 
    447513        $this->assertTrue($Created = $TestMailer->create('utf8_body', $this->recipient)); 
     514 
    448515        $this->assertPattern("/\nFrom: =\?UTF-8\?Q\?Foo_.*?\?= <extended@example.com>\r/", $Created->getEncoded()); 
    449516        $this->assertPattern("/To: =\?UTF-8\?Q\?Foo_.*?\?= <extended@example.com>, Ex=\r\n ample Recipient <me/", $Created->getEncoded()); 
     
    690757     
    691758    /**/ 
    692      
    693     function test_should_render_multipart_message() 
    694     { 
    695         $TestMailer =& new TestMailer(); 
    696         $TestMailer->deliver('multipart_rendering'); 
    697          
    698         echo $TestMailer->getRawMessage(); 
    699     } 
    700      
    701      
    702759} 
    703760 
    704 //Ak::test('Tests_for_Mailers'); 
     761Ak::test('Tests_for_Mailers'); 
    705762Ak::test('Tests_for_AkActionMailer'); 
    706763