Link to home
Start Free TrialLog in
Avatar of AHMED SAMY
AHMED SAMYFlag for Egypt

asked on

i need to send emails using interval way

i need to send emails using interval way

i have email list i need to Periodically send email to this list 70 email in hour

how i can do
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AHMED SAMY

ASKER

thanks i am now tring it
is it right

require "connection.php";

	$sql="SELECT * FROM newsletter WHERE news_type=0";
	$query=mysqli_query($conn,$sql);
	
	while($row=mysqli_fetch_array($query)){
		
		set_time_limit(20);

		$emails = $row['email'];
		
		$to = $emails;
		$subject = "****";
		$txt = "*******";
		$headers = "From: *****";

		mail($to,$subject,$txt,$headers);

		$sql="UPDATE newsletter SET news_type='sent' WHERE email='$emails' ";
		$query=mysqli_query($conn,$sql);

		sleep(55);
	}	
	


?>

Open in new window

I would change the set_time_limit(20) to set_time_limit(60) - in other words more than your sleep time. You could also bring the set_time_limit() outside the loop as set_time_limit(3600)

Other than that the script should be fine.
thanks i will try it