Hello. We implement mailing mail. There is a database of subscribers, there is a mailing template. What we do is choose a template and click send newsletter. Mailing leaves throughout the database. But there is one BUT. Hosting swears and says that in an hour you can send 500 letters. And then the question arose how to make a delay, i.e. they sent 500 letters, a delay per hour, sent another 500 letters, a delay of an hour, and so on. Will the sleep function help? I start the loop, loop through the database, send letters, and as soon as the counter reaches 500, I call the sleep function (3600); Then I continue to run the script. Will it work or just a crutch?

  • Here it is appropriate to use the cron task scheduler. - mJeevas
  • If you have a lot of records in the database, it will hang the server. The host will be unhappy. It would be better to hang up the execution of the script on cron. Only the input data will change (from which record to start the newsletter) - Alexey Shimansky
  • @ Alexey Shimansky and the host will simply chop off the script. There usually is standard on shared hosting max_execution_time 60 seconds - Suvitruf

1 answer 1

  1. As already advised, only crowns and a marker on the database have been sent - this is for shared.
  2. I do not recommend doing the mailing on my own from my IP, as it is easy to get into the black list and then important letters will not reach. Use special mailing services - there are many free ones at the initial stage. If you are worried about confidentiality - you need to raise your mail server - but again, I recommend on a separate IP.
  • Thank! Then hang on Cron - duddeniska