我希望为我的Web应用程序创建一个功能,即一旦用户输入到我的数据库中,每4周就会向他们发送一封电子邮件提醒他们做些反馈之类的事情。我听说cron job是我要找的东西,但我想知道还有什么其他的选择,是否存在php脚本或者简单的方法可以实现?我想要的是类似于从他们进入数据库开始倒计时,直到4周过去,然后调用一个PHP文件或其他东西向他们发送我选择的电子邮件。如果这是可能的,请让我知道!谢谢
30 14 * * * php path/to/some/phpscript.php
<?php
# get all users (or your query could choose only users who signed up (4 weeks)*n ago)
$result = mysql_query('SELECT * FROM user');
$users = array();
while($row = mysql_fetch_assoc($result)) $users[] = $row;
# loop through users and (if you didn't already check) see which ones have signed up (4 weeks)*n ago
foreach ($users as $user) {
# take the number of seconds and convert it to number of days
$today = (int)(strtotime(date('c')) / 60 / 60 / 24);
$signup_day = (int)(strtotime($user['signup_date']) / 60 / 60 / 24);
# check if the amount of days since signup is a multiple of 28 (4*7)
if (($today - $signup_day) && ($today - $signup_day) % 28 == 0) {
send_mail_to($user);
}
}
?>