How to schedule emails to send out

前端 未结 5 1627
独厮守ぢ
独厮守ぢ 2021-02-06 11:57

Using PHP, I have a query that goes through my DB looking for pending tasks with reminder triggers at certain times of the day. I have a cronjob that runs every 10 mins and chec

5条回答
  •  隐瞒了意图╮
    2021-02-06 12:18

    How often do you want to send an email? If it's on occurence (the minute it is discovered by your existing cronjob, i.e. every 10 minutes), you could make the script that looks for the remind-me flag do this:

    1 - add a reference to each row the flag was found in to an array, e.g.

    $reminders = array(1, 3, 212);
    

    Each element in the array references a primary key of your tasks table, here I used "tasks".

    2 - after the database lookup is complete, see if $reminders is not empty and then run a query like

    $query = "SELECT * FROM tasks WHERE id = '".implode(',', $reminders)."'";
    

    to get all the task-specific data

    3 - send an email to youself with this data using mail.

    Was this what you were looking for?

提交回复
热议问题