Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29755

PHP/MYSQL Email reminder when date field is one month before due date

$
0
0

I'm trying to set up an e-mail notification as a reminder to let me know when a device inspection is due, preferably a month in advance. When a date is eleven month later to the date in the due_date inspection table, it should send the reminder "Need a review" to me and to the owner of this device . Your help would be greatly appreciated. Below is the php code and MySQL code:

<?php
//calling PEAR Mailer
require_once "Mail.php";
?>
<?php function connect()
{
  require('includes/config.php');
  return $conn;
}
?>
<?php
// Make a MySQL query
$query = "SELECT * FROM inspection";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result) or die(mysql_error());
$from = "Server Database <admin@server.com>";
$to = "me <me@server.com>";
//$cc = "another person <another@server.com>";
$subject = "Device Inspection Reminder";
$body = "echo "The following device is due for inspection:;
echo $row['device'];
if (!$conn)
  {
  die('Could not connect: ' . mysql_error());
  }

?>";

$host = "mail.server.com";
$username = "username";
$password = "password";

$headers = array ('From' => $from,
  'To' => $to,
  'CC' => $cc,
  'Subject' => $subject);
$smtp = Mail::factory('smtp',
  array ('host' => $host,
    'auth' => true,
    'username' => $username,
    'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
  echo("<p>" . $mail->getMessage() . "</p>");
 } else {
  echo("<p>Message successfully sent!</p>");
 }
?> [events.php][1]


  [1]: https://i.stack.imgur.com/do9Ce.png

Viewing all articles
Browse latest Browse all 29755

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>