0

I don't have any code to share as I'm very unsure where to start with this. But basically I would like to send an email using PHP once a day.

I.e. it will run a piece of script automatically (without a browser / front end) on the server. It will query a MySQL database for any changes, if there are any changes then I want PHP to send an email.

I'm familiar with querying and sending emails, I'm just not sure how to do this automatically without user input/ POST request etc. Can I make an infinite loop or will that block all other scripts on my server? Can this be done in PHP or should I use another language?

If anyone can point me in the right direction? Thanks in advance.

  • 4
    Look into cron scheduling, it will help you do what you want. – aynber Jun 29 '20 at 14:50
  • I dont know if you using a framework with routing, else place the php script you use for the cronjob outside the root of the website directory so you or some one else can't trigger the script trough a browser or place it in a directory with a custom .htaccess file – Baracuda078 Jun 29 '20 at 15:32

1 Answers1

2

You have to set up a cron job that will run the your php script every day. This should help you: How to create cron job using PHP?

heyheygg
  • 56
  • 2