diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php
index 4250893c0..8ab91f05c 100644
--- a/lib/Cake/Network/Email/CakeEmail.php
+++ b/lib/Cake/Network/Email/CakeEmail.php
@@ -1253,7 +1253,7 @@ class CakeEmail {
$formatted[] = '';
continue;
}
- if (!preg_match('/\<[a-z]/i', $line)) {
+ if (!preg_match('/<[a-z]+.+>/i', $line)) {
$formatted = array_merge(
$formatted,
explode("\n", wordwrap($line, $wrapLength, "\n"))
diff --git a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php
index 37991a169..b30e2d8a8 100644
--- a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php
+++ b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php
@@ -1622,6 +1622,58 @@ class CakeEmailTest extends CakeTestCase {
$this->assertContains('ってテーブルを作ってやってたらう', $result['message']);
}
+ public function testWrapLongLine() {
+ $message = '' . str_repeat('x', CakeEmail::LINE_LENGTH_MUST) . "";
+
+ $this->CakeEmail->reset();
+ $this->CakeEmail->transport('Debug');
+ $this->CakeEmail->from('cake@cakephp.org');
+ $this->CakeEmail->to('cake@cakephp.org');
+ $this->CakeEmail->subject('Wordwrap Test');
+ $this->CakeEmail->config(array('empty'));
+ $result = $this->CakeEmail->send($message);
+ $expected = "' . str_repeat('x', CakeEmail::LINE_LENGTH_MUST) . "\r\n\r\n\r\n";
+ $this->assertEquals($expected, $result['message']);
+ }
+
+ public function testWrapIncludeTag() {
+ $message = 'CakePHP';
+
+ $this->CakeEmail->reset();
+ $this->CakeEmail->transport('Debug');
+ $this->CakeEmail->from('cake@cakephp.org');
+ $this->CakeEmail->to('cake@cakephp.org');
+ $this->CakeEmail->subject('Wordwrap Test');
+ $this->CakeEmail->config(array('empty'));
+ $result = $this->CakeEmail->send($message);
+ $expected = "{$message}\r\n\r\n";
+ $this->assertEquals($expected, $result['message']);
+
+ $message = 'fooCakeEmail->send($message);
+ $expected = "{$message}\r\n\r\n";
+ $this->assertEquals($expected, $result['message']);
+ }
+
+ public function testWrapForJapaneseEncoding() {
+ $this->skipIf(!function_exists('mb_convert_encoding'));
+
+ $message = mb_convert_encoding('受け付けました', 'iso-2022-jp', 'UTF-8');
+
+ $this->CakeEmail->reset();
+ $this->CakeEmail->transport('Debug');
+ $this->CakeEmail->from('cake@cakephp.org');
+ $this->CakeEmail->to('cake@cakephp.org');
+ $this->CakeEmail->subject('Wordwrap Test');
+ $this->CakeEmail->config(array('empty'));
+ $this->CakeEmail->charset('iso-2022-jp');
+ $this->CakeEmail->headerCharset('iso-2022-jp');
+ $result = $this->CakeEmail->send($message);
+ $expected = "{$message}\r\n\r\n";
+ $this->assertEquals($expected, $result['message']);
+ }
+
/**
* Tests that the body is encoded using the configured charset
*