Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

CakeEmail recipients not quoted properly #2381

Closed
oldskool opened this Issue Nov 22, 2013 · 2 comments

Comments

Projects
None yet
2 participants
Contributor

oldskool commented Nov 22, 2013

When adding a recipient (either to, cc or bcc) to the CakeEmail Utility in the form of:

$this->Email->to(array('recipient@example.com' => 'Last name, First-name'));

CakeEmail will parse the spaces and comma's as a recipient separator, thus resulting in these recipients:

  1. Last@local.domain
  2. name@local.domain
  3. First-name <recipient@example.com>

On the space and comma, the recipient is split, and since there is no specific domain on the first two, the server falls back to it's local/default domain. It would be cleaner if recipient names are to be quoted, like in this RFC (chapter 3.2.5). So, the recipient would become a single recipient:

"Last name, First-name" <recipient@example.com>

Contributor

oldskool commented Nov 22, 2013

An easy way to reproduce this in the current CakeEmailTest test case is to slightly adjust the testAddresses() test method, simply add a comma to line 451 (current master), so it goes from:

$this->CakeEmail->to('to@cakephp.org', 'To CakePHP');

to

$this->CakeEmail->to('to@cakephp.org', 'To, CakePHP');

Also adjust the assertion on line 462 from

$this->assertSame($this->CakeEmail->to(), array('to@cakephp.org' => 'To CakePHP', 'to2@cakephp.org' => 'To2 CakePHP'));

to

$this->assertSame($this->CakeEmail->to(), array('to@cakephp.org' => 'To, CakePHP', 'to2@cakephp.org' => 'To2 CakePHP'));

So just add the comma's there. When running the test now, the funny thing is that the header assertion (on line 471) actually asserts properly and looks for the quotes, but doesn't receive it:

Failed asserting that two strings are identical
--- Expected
+++ Actual
@@ @@
-"To, CakePHP" <to@cakephp.org>, To2 CakePHP <to2@cakephp.org>
+To CakePHP <to@cakephp.org>, To2 CakePHP <to2@cakephp.org>
Owner

markstory commented Nov 22, 2013

The tests you're suggesting pass for me on master. I'll update the tests though to ensure this stays working.

@markstory markstory closed this in d97cf79 Nov 22, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment