Delay PHP email in cron
Posted: Mon Apr 19, 2010 1:44 pm
Hello All,
I hope I'm posting this in the correct place. I'm currently using cron to run a PHP script daily. The purpose of the script is to check a MYSQL database, and if it finds certain entries older than 2 months, it will send an email to the address associated with the entry. What I want to do is, once this email has been sent, delay the script from sending the email until ANOTHER 2 months has passed (so a total of 4 months from the timestamp in the database).
Is this something I can accomplish through PHP script? Or is there a way for me to configure cron to recognize this?
The current script is below:
Thanks
I hope I'm posting this in the correct place. I'm currently using cron to run a PHP script daily. The purpose of the script is to check a MYSQL database, and if it finds certain entries older than 2 months, it will send an email to the address associated with the entry. What I want to do is, once this email has been sent, delay the script from sending the email until ANOTHER 2 months has passed (so a total of 4 months from the timestamp in the database).
Is this something I can accomplish through PHP script? Or is there a way for me to configure cron to recognize this?
The current script is below:
Code: Select all
<?php
mysql_connect("localhost","xxxxxxxx","xxxxxxx") or die(mysql_error());
mysql_select_db("xxxxxxxx") or die(mysql_error());
$check = mysql_query("SELECT * FROM xxxx WHERE date < DATE_SUB(NOW(), INTERVAL 2 MONTH)");
while($result = mysql_fetch_array($check)) {
$user = $result['username'];
$book = $result['title'];
$thedate = $result['date'];
$check1 = mysql_query("SELECT * FROM users WHERE username = '$user'");
while($result1 = mysql_fetch_array($check1)) {
$email = $result1['email'];
$EmailFrom = "xxxxxxxxxxx";
$Subject = "xxxxxxxx";
$msg = "xxxxxxxxxxxxxxxxxxxx";
mail($email,$Subject,$msg,"From: $EmailFrom");
}
}
?>