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
AHMED SAMYownerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
Assuming you are going to run the script from a cron job you can then vary the number of emails sent using the sleep()

Issue a sleep(50) after each email to force the script to wait 50 seconds before sending the next email. 70 emails will take 3500 seconds which is 100 seconds short of an hour. If you set your cron Job to run on the hour you should be in the ball park.

Also use set_time_limit() to ensure your script does not timeout.
After sending each email call set_time_limit(120) to ensure the server does not stop your script due to a timeout.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AHMED SAMYownerAuthor Commented:
thanks i am now tring it
0
AHMED SAMYownerAuthor Commented:
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

0
Julian HansenCommented:
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.
0
AHMED SAMYownerAuthor Commented:
thanks i will try it
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.