note 11059 deleted from function.mail by jimw
| From: | jimw@php.net | Date: | Wed, 31 Oct 2001 23:11:48 +0000 |
| Subject: | note 11059 deleted from function.mail by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-19892@lists.php.net to get a copy of this message | ||
Lots of people need to send more than one email through a script and some of them want to email
through an entire mailing list or through each database record. And it has been asked of me a few
times how can you do this? So I thought I'd explain it here to for everyones benefit.
Essentially PHP scripts time out after 30 seconds by default so if you have this script merrily
iterating through a while or for loop happily sending out email to each recipient it will end up
timing out in 30 seconds and will never send out all the emails. :(
Ok now the solutions and there are a couple of them:
1.) If you have a dedicated machine you can edit max_execution_time=30; to read
max_execution_time=0; now according to php docs this will disable the max execution time so a script
will never timeout. This however could be a bad thing since ALL scripts you are running will now
never timeout :(
2.)The next solution if you have a virtual host with PHP 3 and it is running as an Apache module in
Unix is to put an .htaccess file in the directory you are running the script in only. Just add the
line ( php3_max_execution_time 0 ) in the .htaccess file and then all scripts in that directory
alone should have the timeout disabled.
3.) The third and best way I think is to use set_time_limit(60); prior to calling the mail function.
This way you can set reset the amount of time the script has before it time's out prior to each
call to mail()
You can get more information on set_time_limit on the php site just use quick ref and search for
set_time_limit
Hope this will be of help to all who need to write mailing list scripts.