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);
}
}
mail()is a slow function. you won't be able to speed it up without dumping it and switching to something better, like PHPMailer or Swiftmailer