diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index bc5b821a7..69c3982c2 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -1109,6 +1109,9 @@ class CakeEmail { $restore = mb_internal_encoding(); mb_internal_encoding($this->_appCharset); } + if (strpos($text, ',') !== false) { + $text = '"' . $text . '"'; + } $return = mb_encode_mimeheader($text, $this->headerCharset, 'B'); if ($internalEncoding) { mb_internal_encoding($restore); diff --git a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php index a3350efc2..a962bab1c 100644 --- a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php +++ b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php @@ -277,6 +277,14 @@ class CakeEmailTest extends CakeTestCase { $expected = array('CakePHP ', 'Cake '); $this->assertSame($expected, $result); + $result = $this->CakeEmail->formatAddress(array('me@example.com' => 'Last, First')); + $expected = array('"Last, First" '); + $this->assertSame($expected, $result); + + $result = $this->CakeEmail->formatAddress(array('me@example.com' => 'Last First')); + $expected = array('Last First '); + $this->assertSame($expected, $result); + $result = $this->CakeEmail->formatAddress(array('cake@cakephp.org' => 'ÄÖÜTest')); $expected = array('=?UTF-8?B?w4TDlsOcVGVzdA==?= '); $this->assertSame($expected, $result);