Reputation: 1947
I want to make a PHP newsletter sender for a few hundred people, say monthly.
Does it work for me to send all the emails through a for()
loop? i.e. will it use an excessive amount of resources? Also, should I sleep()
for a period between each email I send?
Note: to send the emails, i use the PEAR Mail::factory('smtp' ...);
function.
Upvotes: 1
Views: 518
Reputation: 21
You can use a for
loop for sending 100 emails, but I don't know about the sleep()
. I have sent 200 mails at a time using PHP mailer in a for
loop.
Upvotes: 0
Reputation: 10732
If you're sending to a couple of hundred people, there shouldn't be too many problems.
Things to bear in mind are whether you're going to be sending individual emails, or if you're sending the same email to multiple people using BCC - the former will mean you send fewer emails, but you can't then personalise them at all.
You can definitely loop through the database with a for loop; if you're going to be sending individual emails, then I would recommend the occasional sleep(), too, just so you don't hit the mailserver too hard. It might be worth talking to them first, to let them know - they'd probably appreciate knowing that you're going to be doing that, especially if your newsletter subscribers grow into the thousands.
Upvotes: 1