Here is a very simple but functional way to send notices to users
Server: Ubuntu
Email Server: sendmail
1.- You need to install lynx
sudo apt-get install lynx
2.- Create your query. I use mysql_connect because I transfer data from Pervasive to MySQL. But you can modify it to odbc_connect()
This simple php script will do "something" everytime if find a record.
<?
//conneccion
mysql_connect("localhost", "root", "") or die("Unable to connect to SQL server");
//sql script
$sql="SELECT EID, SONUM, CUSNME, PCODE, PDESC FROM uni_ship_email WHERE ESTATUS='N'";
$result = mysql_db_query("umcnet", $sql) or die("Unable to select Database");
$row = mysql_num_rows($result);
while ($row = mysql_fetch_array($result)) {
$EID=$row["EID"];
$SONUM=$row["SONUM"];
$CUSNME=$row["CUSNME"];
$PCODE=$row["PCODE"];
//-------------------------EMAIL IT
$to = "john_doe@home.com";
$from_header = "UNI Ship/Rec Server";
$subject = "UNI SHP/REC NEW ITEM RECVD. SO: ".$SONUM;
$body = "A New Item has been received.\n\nSO Number: ".$SONUM."\n\nSKU: ".$PCODE;
mail($to, $subject, $body, $from_header);
//-------------------------UPDATE RECORD
$sq = "UPDATE uni_ship_email SET ESTATUS='Y' WHERE EID=$EID";
mysql_db_query("umcnet", $sq) or die("Unable to select Database");
}
mysql_close();
?>
3.- Add a Cron Job
open /var/spool/cron/crontabs/root
add the following line
0,15,30,45 * * * * lynx -dump
http://intranet/uni/SHIP/send_email.php where "
http://intranet/uni/SHIP/send_email.php" is the path to your script on your website.
Done!!
It will send an email whenever finds a record
Regards,
Kelloggs