Email Component should accept an array
Reported by Braindead | February 2nd, 2010 @ 01:14 AM | in 1.3.0
The to variable only accepts a string. Sending an email to more than one addresse requires the addresses to be separated by a comma. As the cc and bcc variables both accept an array this behavior is not very intuitive.
I made a contribution to the cookbook to document this behavior, but making the to variable accept an array is the better way.
Comments and changes to this ticket
-

Mark Story February 2nd, 2010 @ 07:42 PM
- → Tag changed from emailcomponent to emailcomponent, enhancement
- → Milestone set to 1.3.0
-

Rachman Chavik February 3rd, 2010 @ 11:32 PM
Hi,
I have tried to implement this in my fork: http://github.com/rchavik/cakephp1x/tree/ticket_293
Here are the:
-

Juan Basso February 4th, 2010 @ 04:19 AM
I can take and suggest something else? Allow the array to put the realname, example:
array('Root' => 'root@localhost', 'Juan Basso' => 'jrbasso@gmail.com', 'other@single.mail');It must be generate something like: "To: Root <root@localhost>, Juan Basso <jrbasso@gmail.com>, other@single.mail"
-

Phally February 4th, 2010 @ 05:50 AM
This can easily be achieved with a wrapper component (or place it in the controller) which implements something like this:
@@@ PHP private function assignProperties($options) {
foreach($options as $property => $value) { if (property_exists($this->Email, $property)) { $this->Email->{$property} = $value; } }}
-

Phally February 4th, 2010 @ 05:51 AM
Formatting isn't my friend... Again:
private function assignProperties($options) { foreach($options as $property => $value) { if (property_exists($this->Email, $property)) { $this->Email->{$property} = $value; } } } -

Phally February 4th, 2010 @ 05:55 AM
Ok, obviously I didn' t read good enough, I was under the impression the parameters should all be passed as an array. I think though, making those array values is a good idea.
-

Mark Story February 4th, 2010 @ 08:56 PM
- → Assigned user set to Mark Story
You wouldn't need an
assignPropertiesmethod either. Its effectively a clone ofObject::_set(). -

-

CakePHP February 7th, 2010 @ 03:46 PM
- → State changed from new to resolved
(from [a20c809796bf143b53488b9d3f7c50728a46ac06]) EmailComponent: Accept arrays for $to variable (closes #293) http://github.com/cakephp/cakephp1x/commit/a20c809796bf143b53488b9d...
-

Dean Sofer December 16th, 2010 @ 08:56 PM
I may be wrong, but I am not sure the 'key' => 'value' approach of email addresses works. Examining the code I don't see where the keys get passed, only the values, and I have been unsuccessful at producing this effect.
Also, is it not permitted to have multiple emails for 'replyTo'? If it is, would it be plausible to then add this functionality for that field as well?
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
Source available from github
Repository is at http://github.com/cakephp/cakephp
Creating a bug report
When creating a bug report, please include as much relevant information as possible. Please include code to reproduce the issue. Or even better, make a unit test. Either change an existing test or add a new test to show that the expected behavior is not occuring.
People watching this ticket
Referenced by
-
#293 Email Component should accept an array
(from [a20c809796bf143b53488b9d3f7c50728a46ac06])
EmailCo...