...

View Full Version : Sending email to multiple persons



bhagyaa2ze
03-16-2007, 06:51 AM
Hi,Iam new to PHP.

I know how to send the email for a single person,Iam using SMTP server,now I want to send a email to a multiple persons at a time.Please help me how to code for this.Please send 1 example.

Inigoesdr
03-16-2007, 07:11 AM
Use an array (http://www.php.net/array) to make a list of the e-mails(or use a comma-delimited string and explode() (http://www.php.net/explode) it) and then use foreach() (http://www.php.net/foreach) to loop through them, sending the message to each person.
Something like this:

$emails = array('first@email.com','second@email.com');
foreach($emails as $addr)
{
// mail($addr, 'subject', 'message');
}

felgall
03-16-2007, 07:15 AM
If there isn't any privacy iissue with showing all the recipient names at the top of the email then you can supply all the addresses in the one field as a comma separated list.

Inigoesdr
03-16-2007, 07:21 AM
That's true, or you could even do a BCC with the headers. I had forgotten about that.

the-dream
03-16-2007, 10:54 AM
You should use a MySQL DB, to store all the emails. Then Send them to the required addresses as necessary.

hessodreamy
03-16-2007, 12:28 PM
how many people are you sending to? And will the content change for each recipient (eg having their name in the mail).

The mail() function is pretty clunky and can slow up a server, so if you need to send a lot of emails at once then you might want to try an external class like swiftmail.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum