View Full Version : Sending email to multiple persons
03-16-2007, 05: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.
03-16-2007, 06: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('email@example.com','firstname.lastname@example.org');
foreach($emails as $addr)
// mail($addr, 'subject', 'message');
03-16-2007, 06: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.
03-16-2007, 06:21 AM
That's true, or you could even do a BCC with the headers. I had forgotten about that.
03-16-2007, 09:54 AM
You should use a MySQL DB, to store all the emails. Then Send them to the required addresses as necessary.
03-16-2007, 11:28 AM
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.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.