I am running this script it is fine for one context but when I try this on 4 recipients it is not working just showing this error:
Fatal error: Maximum execution time of 30 seconds exceeded in D:\Hosting\8011955\html\admin\newsletter.php on line 60
How can I improve this code? I just want to send email not more than 200.
here is the code:
if(!(is_array($errors)))
{
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= "From: \"".$from_name."\" <".$from_email.">\n";
$query="SELECT email From newsletter WHERE visible='1'";
$result=mysql_query($query) or mysql_error();
while($rowdata=mysql_fetch_array($result))
{
$headers .= "To: \"".$to_name."\" <".$rowdata['email'].">\n";
mail($rowdata['email'], "$sub",$message, $headers);
}
}
By default, PHP scripts run for 30 seconds and then stop. This value is controlled by the
max_execution_timevalue in php.ini. You can override this value within the current script by calling theset_time_limit()function. Each time you callset_time_limit()the script execution timer starts over at zero. So you can put it inside of yourwhile {}loop to give your script as much time as it needs.