Hi, I have a php script that send emails, I want it to run daily on the server.
I thought that CRON JOB can do that for me but the guy who owns the server told me now that he can only run SH file? shell script if I'm not wrong..the server is Linux btw..
so what am I supposed to do with my php script? is it worthless? do I need to write a new code with this shell script? (don't know what that is..)
here's my code so far..
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD, TRUE) or die('Error connecting to MySQL server.');
mysql_selectdb(DB_NAME,$link)or die ('Error selecting to MySQL server.');
$today = date("Y-m-d");
$query ="SELECT *
FROM tblreminder
WHERE alertDate='$today'";
$result = mysql_query($query,$link)or die(' Error querying database.');
while ($row = mysql_fetch_array($result)){
require_once("Mail.php");
$from = "x@y.com";
$to=$row['email'];
$subject = $row['title'];
$body = $row['content'];
$host = "xyz";
$port = "xy" ;
$headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject);
$smtp = Mail::factory('smtp', array ('host' => $host, 'port' => $port));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
}