Can anyone help?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
suey
Forum Newbie
Posts: 2
Joined: Mon May 25, 2009 6:35 am

Can anyone help?

Post by suey »

I need to know how to separate receivers of an email in a $to variable.

I have written:
$to = "email@aaa.com.au";"email2@aaa.com.au"

and it only goes to the first email address - how should I write it?
Thanks in advance for your help - this is driving me insane
Turv
Forum Commoner
Posts: 25
Joined: Fri Mar 13, 2009 3:56 pm

Re: Can anyone help?

Post by Turv »

suey wrote:I need to know how to separate receivers of an email in a $to variable.

I have written:
$to = "email@aaa.com.au";"email2@aaa.com.au"

and it only goes to the first email address - how should I write it?
Thanks in advance for your help - this is driving me insane
Seperate them via comma's instead of semi-colons. for example:

Code: Select all

$to = "email1@domain.com, email2@domain.com";
However, when the user receives it, they will see who you have sent an email to, so you may want to send a seperate email for each address, to do this you can put it into an array.

Code: Select all

$Emails = "email1@domain.com, email2@domain.com";
 
// Split emails into an array
$ToArray = explode(",",$Emails);
 
// 1 loop for each email address
foreach($ToArray as $To) {
// Send mail, $To variable contains the current email address.
}
 
suey
Forum Newbie
Posts: 2
Joined: Mon May 25, 2009 6:35 am

Re: Can anyone help?

Post by suey »

Thanks, I've tried it out and it works. You're a saviour!!
Post Reply