Page 1 of 1
Adding recipients by means of an array
Posted: Tue Oct 17, 2006 5:52 am
by joho
JayBird | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I added a few recipients like this:
Code: Select all
$rcps = new array ();
for ($i=0; $i<count($myrecips); $i++)
$rcps[] = array ('', $myrecips[$i]);
This resulted in a message being created with a header like this:
To: "" <
admin@mydomain.com>
I assume I did something wrong?
JayBird | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Posted: Tue Oct 17, 2006 5:58 am
by JayBird
You didnt add the recipient name in the array like so..
Code: Select all
$rcps = new array ();
for ($i=0; $i<count($myrecips); $i++)
$rcps[] = array ('Recipient name here', $myrecips[$i]);
Posted: Tue Oct 17, 2006 6:05 am
by joho
Indeed; and that is intentional -- I may (or may not) have a name.
(sorry about the bad format in the original post)
Proposed changes
Posted: Tue Oct 17, 2006 6:20 am
by joho
My proposed change to the way the recipient array is handled is as follows:
If an array-item in the passed list contains only one element, use it as the recipient's e-mail address and set the recipient's name to nothing, otherwise carry on as the current code does. Perhaps this should be an option, but possible nonetheless.
Re: Proposed changes
Posted: Tue Oct 17, 2006 7:26 am
by Chris Corbyn
joho wrote:My proposed change to the way the recipient array is handled is as follows:
If an array-item in the passed list contains only one element, use it as the recipient's e-mail address and set the recipient's name to nothing, otherwise carry on as the current code does. Perhaps this should be an option, but possible nonetheless.
Hmmm that's already how it works. One-dimensional reads each element as an address. 2-dimensional reads names and addresses.
Code: Select all
$recipients = array('address@one.tld', 'address@two.tld', 'address@three.tld'); //1-dimensional
$swift->send($recipients, .... ); //Send to each of the recipients
Re: Proposed changes
Posted: Tue Oct 17, 2006 8:25 am
by JayBird
d11wtq wrote:
Hmmm that's already how it works. One-dimensional reads each element as an address. 2-dimensional reads names and addresses.
i think he means if you had a 2-dimensional array, but some of the names may not be entered, so have a default value when the name is empty.
Posted: Tue Oct 17, 2006 8:48 am
by joho
Indeed; I may not know the status of each "data pair" before I create the recipients array. And when it's available, it's of course always nicer to present a name along with the address. But I don't think a construct of
is a good idea

Posted: Tue Oct 17, 2006 9:01 am
by Chris Corbyn
joho wrote:Indeed; I may not know the status of each "data pair" before I create the recipients array. And when it's available, it's of course always nicer to present a name along with the address. But I don't think a construct of
is a good idea

Point taken

I'll make some changes when I get in from work.
Posted: Tue Oct 17, 2006 6:33 pm
by Chris Corbyn
Gahh I forgot to make this change when I just put the new release out

Posted: Wed Oct 18, 2006 2:37 am
by joho
Don't sweat it; it's not a show stopper. I've removed the usage of recipient names for now, and just supply the function with an array of e-mail addresses. It works, and I can live with it for now.