Changeset 946
- Timestamp:
- 07/23/08 20:41:17 (3 months ago)
- Files:
-
- branches/action_mailer/lib/AkActionMailer.php (modified) (10 diffs)
- branches/action_mailer/lib/AkActionMailer/AkMailBase.php (modified) (9 diffs)
- branches/action_mailer/lib/AkActionMailer/AkMailComposer.php (modified) (6 diffs)
- branches/action_mailer/lib/AkActionMailer/AkMailDelivery/AkPhpMailDelivery.php (modified) (1 diff)
- branches/action_mailer/lib/AkActionMailer/AkMailDelivery/AkSmtpDelivery.php (modified) (2 diffs)
- branches/action_mailer/lib/AkActionMailer/AkMailDelivery/AkTestDelivery.php (modified) (1 diff)
- branches/action_mailer/lib/AkActionMailer/AkMailMessage.php (modified) (2 diffs)
- branches/action_mailer/lib/AkActionMailer/AkMailPart.php (modified) (1 diff)
- branches/action_mailer/test/fixtures/app/models/test_mailer.php (modified) (1 diff)
- branches/action_mailer/test/fixtures/app/views/test_mailer/alternative_message_from_templates.text.html.tpl (modified) (1 diff)
- branches/action_mailer/test/unit/lib/AkActionMailer.php (modified) (11 diffs)
- branches/action_mailer/test/unit/lib/AkActionMailer/AkMailEncoder.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/action_mailer/lib/AkActionMailer.php
r934 r946 21 21 require_once(AK_LIB_DIR.DS.'AkActionMailer'.DS.'AkMailParser.php'); 22 22 require_once(AK_LIB_DIR.DS.'AkActionMailer'.DS.'AkActionMailerQuoting.php'); 23 require_once(AK_LIB_DIR.DS.'AkActionMailer'.DS.'AkMailComposer.php'); 23 24 24 25 ak_define('MAIL_EMBED_IMAGES_AUTOMATICALLY_ON_EMAILS', false); … … 276 277 var $helpers = array('mail'); 277 278 var $Message; 279 var $Composer; 278 280 var $_defaultMailDriverName = 'AkMailMessage'; 279 281 … … 538 540 $Message->send(); 539 541 } 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 } 540 552 541 553 … … 546 558 function &create($method_name, $parameters, $content_type = '') 547 559 { 548 require_once(AK_LIB_DIR.DS.'AkActionMailer'.DS.'AkMailComposer.php'); 549 $Composer =& new AkMailComposer(); 550 $Composer->init($this); 560 $Composer =& $this->getComposer(); 551 561 $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; 553 564 return $this->Message; 554 565 } … … 572 583 $this->{"perform".ucfirst(strtolower($this->delivery_method))."Delivery"}($this->Message); 573 584 } 585 $this->Message->_has_been_delivered_by_mailer = true; 574 586 return $this->Message; 575 587 } … … 588 600 $settings = array_merge($default_settings, $settings); 589 601 590 return $this->_deliverUsingMailDeliveryMethod('S MTP', $Message, $settings);602 return $this->_deliverUsingMailDeliveryMethod('Smtp', $Message, $settings); 591 603 592 604 } … … 594 606 function performPhpDelivery(&$Message, $settings = array()) 595 607 { 596 return $this->_deliverUsingMailDeliveryMethod('P HPMail', $Message, $settings);608 return $this->_deliverUsingMailDeliveryMethod('PhpMail', $Message, $settings); 597 609 } 598 610 … … 657 669 } 658 670 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 660 690 /** 661 691 * Alias for getModelName … … 715 745 return $helpers; 716 746 } 717 747 718 748 function _deliverUsingMailDeliveryMethod($method, &$Message, $options) 719 749 { … … 729 759 } 730 760 $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 742 766 743 767 } branches/action_mailer/lib/AkActionMailer/AkMailBase.php
r934 r946 51 51 $this->body = stristr($content_type,'text/') ? str_replace(array("\r\n","\r"),"\n", $body) : $body; 52 52 if($content_type == 'text/html'){ 53 AkMailParser::extractImagesIntoInlineParts($this); 53 $Parser = new AkMailParser(); 54 $Parser->extractImagesIntoInlineParts($this); 54 55 } 55 56 }else{ … … 157 158 foreach ((array)$Mail as $field => $value){ 158 159 if(!empty($value) && is_string($value)){ 159 if( strtolower(get_class($Mail)) == 'akmailmessage'&& $field=='body'){160 if($Mail->isMainMessage() && $field=='body'){ 160 161 $result .= $value."\n"; 161 162 }elseif(empty($Mail->data) && $field=='body'){ … … 176 177 } 177 178 } 179 178 180 return $result; 179 181 } 180 182 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'; 186 197 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 } 189 203 } 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]; 192 210 } 193 211 } … … 273 291 } 274 292 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; 283 304 } 284 305 … … 287 308 if(empty($this->headers) || $force_reload){ 288 309 $this->loadHeaders(); 310 $this->_addHeaderAttributes(); 289 311 } 290 312 return $this->headers; … … 299 321 function loadHeaders() 300 322 { 301 if(empty($this->date) && empty($this->_skip_adding_date_to_headers)){323 if(empty($this->date) && $this->isMainMessage()){ 302 324 $this->setDate(); 303 325 } … … 532 554 } 533 555 556 function hasParts() 557 { 558 return !empty($this->parts); 559 } 560 534 561 function hasNonAttachmentParts() 535 562 { … … 557 584 $options = array_merge($options, is_string($arg_options) ? array('body'=>$arg_options) : (array)$arg_options); 558 585 $options = array_merge(array('content_disposition' => 'attachment', 'content_transfer_encoding' => 'base64'), $options); 586 559 587 $this->setPart($options); 560 588 } … … 587 615 function getEncoded() 588 616 { 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(); 590 618 } 591 619 branches/action_mailer/lib/AkActionMailer/AkMailComposer.php
r934 r946 7 7 var $ActionMailer; 8 8 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 12 15 function init(&$ActionMailer) 13 16 { … … 15 18 $this->Message =& $ActionMailer->Message; 16 19 } 17 20 18 21 function build() 19 22 { … … 34 37 } 35 38 } 36 39 37 40 38 41 function _prepareInlineBodyParts($message_content_type = 'multipart/alternative') … … 141 144 142 145 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(); 156 197 }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 170 257 171 258 function compose(&$Mail) … … 196 283 } 197 284 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 198 311 function composePart($Part) 199 312 { 200 return $this->compose($Part);313 return $this->compose($Part); 201 314 } 202 315 … … 205 318 function getMultipartMessage() 206 319 { 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 238 337 */ 239 338 branches/action_mailer/lib/AkActionMailer/AkMailDelivery/AkPhpMailDelivery.php
r934 r946 4 4 class AkPhpMailDelivery extends AkObject 5 5 { 6 function deliver(&$M essage, $settings = array())6 function deliver(&$Mailer, $settings = array()) 7 7 { 8 $Message =& $Mailer->Message; 8 9 return mail($Message->getTo(), $Message->getSubject(), $Message->bodyToString(), $Message->_getHeadersAsText()); 9 10 } branches/action_mailer/lib/AkActionMailer/AkMailDelivery/AkSmtpDelivery.php
r934 r946 4 4 class AkSmtpDelivery extends AkObject 5 5 { 6 function deliver(&$M essage, $settings = array())6 function deliver(&$Mailer, $settings = array()) 7 7 { 8 $Message =& $Mailer->Message; 9 8 10 $SmtpClient =& Mail::factory('smtp', $settings); 9 11 … … 47 49 } 48 50 49 if (PEAR::isError($smtp->data($M essage->getRawMessage()))) {51 if (PEAR::isError($smtp->data($Mailer->getRawMessage()))) { 50 52 return PEAR::raiseError('unable to send data'); 51 53 } branches/action_mailer/lib/AkActionMailer/AkMailDelivery/AkTestDelivery.php
r934 r946 4 4 class AkTestDelivery extends AkObject 5 5 { 6 function deliver(&$M essage, $settings = array())6 function deliver(&$Mailer, $settings = array()) 7 7 { 8 $settings['ActionMailer']->deliveries[] =& $M essage->getEncoded();8 $settings['ActionMailer']->deliveries[] =& $Mailer->Message->getEncoded(); 9 9 } 10 10 } branches/action_mailer/lib/AkActionMailer/AkMailMessage.php
r934 r946 122 122 return AkActionMailerQuoting::quoteIfNecessary($this->subject, $charset); 123 123 } 124 124 125 125 function _getMessageHeaderFieldFormated($address_header_field) 126 126 { … … 128 128 return join(", ",AkActionMailerQuoting::quoteAnyAddressIfNecessary(Ak::toArray($address_header_field), $charset)); 129 129 } 130 131 132 function getRawMessage() 133 { 134 return AkMailComposer::getRawMessage($this); 135 } 130 136 } 131 137 branches/action_mailer/lib/AkActionMailer/AkMailPart.php
r915 r946 5 5 6 6 7 function _prepareHeadersForRendering()7 function prepareHeadersForRendering() 8 8 { 9 9 $this->_removeUnnecesaryHeaders(); 10 $this->_addHeaderAttributes();11 10 } 12 11 branches/action_mailer/test/fixtures/app/models/test_mailer.php
r934 r946 324 324 )); 325 325 } 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 } 331 336 332 337 function &receive($raw_email) branches/action_mailer/test/fixtures/app/views/test_mailer/alternative_message_from_templates.text.html.tpl
r934 r946 6 6 <p>Akelos framework Logo</p> 7 7 8 {?include_logo} 9 <img src="/images/akelos_framework_logo.png" /> 10 {end} 8 11 <hidden> 9 12 <img src="http://www.bermilabs.com/images/bermilabs_logo.png" /> 10 11 <img src="/images/akelos_framework_logo.png" />12 13 </hidden> 13 14 branches/action_mailer/test/unit/lib/AkActionMailer.php
r934 r946 181 181 } 182 182 183 184 185 /** /183 184 185 /** / 186 186 function test_nested_parts() 187 187 { … … 189 189 $Created = $TestMailer->create('nested_multipart', $this->recipient); 190 190 191 191 192 192 $this->assertEqual(2, count($Created->parts)); 193 193 $this->assertEqual(2, count($Created->parts[0]->parts)); … … 197 197 $this->assertEqual( "akmailpart", strtolower(get_class($Created->parts[0]->parts[0]))); 198 198 $this->assertEqual( "text/plain", $Created->parts[0]->parts[0]->content_type ); 199 199 200 200 $this->assertEqual( "text/html", $Created->parts[0]->parts[1]->content_type ); 201 201 $this->assertEqual( "application/octet-stream", $Created->parts[1]->content_type ); 202 202 203 203 204 204 return; 205 205 $TestMailer =& new TestMailer(); … … 211 211 $this->assertEqual('test.txt', $Attachment->original_filename); 212 212 $this->assertEqual('test abcdefghijklmnopqstuvwxyz', $Attachment->body); 213 213 214 214 $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 217 217 } 218 218 … … 238 238 $this->assertTrue($Created = $TestMailer->create('signed_up', $this->recipient)); 239 239 $this->assertEqual($Expected->getEncoded(), $Created->getEncoded()); 240 240 241 241 $this->assertTrue($TestMailer->deliver('signed_up', $this->recipient)); 242 242 $this->assertTrue(!empty($TestMailer->deliveries[0])); 243 243 $this->assertEqual($Expected->getEncoded(), $TestMailer->deliveries[0]); 244 245 } 246 247 244 245 } 246 247 248 248 function test_custom_template() 249 249 { … … 257 257 $this->assertTrue($Created = $TestMailer->create('custom_template', $this->recipient)); 258 258 $this->assertEqual($Expected->getEncoded(), $Created->getEncoded()); 259 259 260 260 } 261 261 … … 325 325 $this->assertTrue(!empty($TestMailer->deliveries[0])); 326 326 $this->assertEqual($Expected->getEncoded(), $TestMailer->deliveries[0]); 327 327 328 328 $this->assertEqual($Created->getSubject(), '=?ISO-8859-1?Q?testing_is=F8_charsets?='); 329 329 330 330 } 331 331 … … 351 351 $this->assertTrue(!empty($TestMailer->deliveries[0])); 352 352 $this->assertEqual($Expected->getEncoded(), $TestMailer->deliveries[0]); 353 353 354 354 $this->assertEqual($Created->getSubject(), 'testing unencoded subject'); 355 355 } 356 356 357 357 358 358 function test_perform_deliveries_flag() 359 359 { … … 369 369 370 370 } 371 371 372 372 373 373 function test_unquote_quoted_printable_subject() … … 624 624 } 625 625 626 626 627 627 function test_implicitly_multipart_messages() 628 628 { … … 736 736 $this->assertTrue(!empty($Mail->from)); 737 737 } 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 739 783 /**/ 740 784 } 741 785 742 Ak::test('Tests_for_Mailers');786 //Ak::test('Tests_for_Mailers'); 743 787 Ak::test('Tests_for_AkActionMailer'); 744 788 branches/action_mailer/test/unit/lib/AkActionMailer/AkMailEncoder.php
r934 r946 23 23 $TestMailer =& new TestMailer(); 24 24 $Delivered = $TestMailer->deliver('alternative_message_from_templates', $this->recipient); 25 $MailComposer = new AkMailComposer($Delivered); 26 25 27 26 echo $MailComposer->compose($Delivered); 28 27 }
