0

i am runing this script it is fine for one contect but when i try this on 4 recepients 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

please help me to improve this code..
Thanks 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);
                }	
	}
3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by Stefano Mtangoo
0

Try the following:

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();
		for ($i=0;$rowdata=mysql_fetch_array($result) && $i<200;$i++)
		{
		   $headers .= "To: \"".$to_name."\" <".$rowdata['email'].">\n";	
	           mail($rowdata['email'], "$sub",$message, $headers);
                }	
	}
0

when messing up with mime it is better to use third party packages that will save you pain like PHPMailer or swiftmailer

I find it better to use the in built mail function because it uses the local mail server rather than a third party mail server. Also using the mail function can speed things up if you have configured the mail function correctly in the php.ini file along with an active mail server on the local server. :)

1

I find it better to use the in built mail function because it uses the local mail server rather than a third party mail server. Also using the mail function can speed things up if you have configured the mail function correctly in the php.ini file along with an active mail server on the local server. :)

I agree with you but for newbees, dealing with mime is not funny :)

Votes + Comments
agreed :)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.