Alex Rivera | Logout

Sending +-200 emails using php mail() function in a loop

Asked 2010-04-14T17:11:46.463
10

Note: It is worth noting that the mail() function is not suitable for larger volumes of email in a loop. This function opens and closes an SMTP socket for each email, which is not very efficient. Source: PHP manual

What are larger volumes? A 100 or a 1000?? Can I safely make it loop 200 times without much problems? (I can't install pear)

Edit
Report

1 Answer

0

You need to first have a look at the your Terms Of Service (TOS) with your hosting or upstream provider. If you cause trouble for them, and you're in violation of the TOS, they'll drop you like a hot spoon.

Next, you may be able to avoid overwhelming the mail system and stay below the radar of any "reaper bots" by simply adding a sleep() call every 10 messages or so. Make it adjustable so that you can limit both the number of iterations and the sleep delay. Eitehr as parameters, or via a config file (the latter could be polled at the top of the loop, to make adjustments on-the-fly.

answered 2010-04-14T17:18:38.117

Your Answer