I am not able to run an application of sending mail to customer using cron job because I have following problem - 1) I am using php -q /sanganak.co.in/sunil/showdata3.php to run showdata3.php file. But at the place of running this file it sends a mail to me from '<cron daemon <root @root fastcpanel.com>'after every 1 minute. Because I have given delay as 1 minute. 2) After setting delay as every day or every month when I come outside of this option it changes it's setting to every minute, every month, every day, every weekday and send me mail after every minute. while I want to set it every day. My showdata3.php code is following <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php $con = mysql_connect("localhost","sanganak_manish","manish"); //$con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("sanganak_mydata",$con); $result = mysql_query("SELECT name,age,DATEDIFF(exp_dt,NOW()) as date_diff FROM mytable"); while($row = mysql_fetch_array($result)) { if($row['date_diff']<30) { $to = 'kharearchana@gmail.com'; $subject = 'the subject'; $message = 'hello I am archana'; $headers = 'From: ' . "\r\n" . 'Reply-To: ' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" echo $mail_sent ? "Mail sent" : "Mail failed"; } else echo "not less than 30"; }mysql_close($con); ?> </body> </html>
1. you need to send email to custumer so frtch his email from db .Script is doing correct but not what you want. 2. Go and setup the cron in advance mod ,if it still has prob contact your host Regards Alex