sql - Send mail automatically near MySQL datetime -



sql - Send mail automatically near MySQL datetime -

in mysql database have table containing datetime column. i'd send emails whenever current time 30 minutes before 1 of datetime values. e.g. datetime value '20140623180000' server should send mail service @ 17:30 on 23rd june 2014. values in datetime column aren't regular. knows how in easy way? (linux running on server)

so need cron run every min looks records datetime < currenttime

then loop through results , send necessary email.

i.e.

#!/usr/bin/php <?php $db = new pdo($dsn); $stmt = $db->query("select * table datetime > ?"); $stmt->execute(array(date("y-m-d h:i:s", strtotime("-30 minutes"))); $r = $stmt->fetchall(pdo::fetch_assoc); foreach($r $res){ mail($to, $subject, $message, $headers); } ?> not tested

mysql sql email datetime

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -