diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index 6268570ec..4250893c0 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -319,8 +319,8 @@ class CakeEmail { /** * Constructor - * @param array|string $config Array of configs, or string to load configs from email.php * + * @param array|string $config Array of configs, or string to load configs from email.php */ public function __construct($config = null) { $this->_appCharset = Configure::read('App.encoding'); @@ -1566,6 +1566,12 @@ class CakeEmail { $render = str_replace(array("\r\n", "\r"), "\n", $render); $rendered[$type] = $this->_encodeString($render, $this->charset); } + + foreach ($rendered as $type => $content) { + $rendered[$type] = $this->_wrap($content); + $rendered[$type] = implode("\n", $rendered[$type]); + $rendered[$type] = rtrim($rendered[$type], "\n"); + } return $rendered; } diff --git a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php index e76b63750..37991a169 100644 --- a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php +++ b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php @@ -1081,6 +1081,30 @@ class CakeEmailTest extends CakeTestCase { $this->assertContains('To: ', $result['headers']); } +/** + * testSendRenderWithHTML method and assert line length is kept below the required limit + * + * @return void + */ + public function testSendRenderWithHTML() { + $this->CakeEmail->reset(); + $this->CakeEmail->transport('debug'); + + $this->CakeEmail->from('cake@cakephp.org'); + $this->CakeEmail->to(array('you@cakephp.org' => 'You')); + $this->CakeEmail->subject('My title'); + $this->CakeEmail->config(array('empty')); + $this->CakeEmail->emailFormat('html'); + $this->CakeEmail->template('html', 'default'); + $result = $this->CakeEmail->send(); + + $this->assertTextContains('
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae
, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est.
+#header h1 a {
+ display: block;
+ width: 300px;
+ height: 80px;
+}
+Some more Bold test.