You can also use ini_set or .htaccess to increase the max execution time for the PHP script. I have some reports that used to take 5 or 6 minutes to run and this worked well, note though that IE has a timeout where it will close the connection if the page has not finished loading within n seconds, you can increase it in the registry.

Rather than waiting for mail() to complete for each e-mail you want to send an often recommended approach is writing the e-mail directly into the mail queue so your mail client picks it up when it runs. Take a look at the PEAR Mail class, it is easy to use and supports multiple backends (http://pear.php.net).

Jason

Kae Verens wrote:

Ryan A wrote:

Hi everyone,
I am trying to create a new newsletter software as the ones i found on
hotscripts were just not good enough or mucho $$ which i dont have :-(

Have finished the basics but need some advise now.
I am using a mysql database instead of text files.

I have a table with the fields "name" and "email", my questions are,
1:is it better to use a for loop and then send each mail?
2:should i first put all the names and addresses into an array?
3:Is it better to send each mail independantly or use BCC? (one mail
blast....., will it work?)


For short lists of emails, yes, it should be fine to send them in one go (one after the other). However, it takes time to send an email, and you are usually allowed only about 30 seconds of CPU time for your script.
How I do it is to make a file listing the ids of the users, and the ids of the emails they're to receive, then I have a cron job which sends out one a minute.
For heavier loads, you could add another cron job to get two a minute, and so on.


Kae


-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to