Add 'mail-cron.php'

This commit is contained in:
jeffreyv
2019-08-15 11:47:44 +02:00
parent 5db70cf69c
commit cf6e9eec94

30
mail-cron.php Normal file
View File

@@ -0,0 +1,30 @@
<?php
define('DB_SERVER', '');
define('DB_USERNAME', '');
define('DB_PASSWORD', '');
define('DB_NAME', '');
/* Attempt to connect to MySQL database */
$link = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
$msg = 'There are open tickets in SYSDesk!';
$sql = "SELECT * FROM tickets";
if($result = mysqli_query($link, $sql)){
if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_array($result)){
mail('J.vos@ictmaatwerk.com','Sample Form',$msg,);
echo "Mail succesfully sent.";
}
mysqli_free_result($result);
} else{
echo "No tickets were found.";
}
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
?>