title: PHP e-mail reminder when date field is one month before due date
body: <p>I'm trying to set up an e-mail notification as a reminder to let me know when a vehicle inspection is due, preferably a month in advance. When a date is one month prior to the date in the due_date inspection table, it should send the reminder. Your help would be greatly appreciated. Below is the php code and MySQL schema I have so far:</p>
  
  <pre><code>&lt;?php
  //calling PEAR Mailer
  require_once "Mail.php";
  ?&gt;
  &lt;?php function connect()
  {
    require('includes/config.php');
    return $conn;
  }
  ?&gt;
  &lt;?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 &lt;admin@server.com&gt;";
  $to = "me &lt;me@server.com&gt;";
  //$cc = "another person &lt;another@server.com&gt;";
  $subject = "Vehicle Inspection Reminder";
  $body = "echo "The following vehicle is due for inspection:;
  echo $row['vehicle'];
  if (!$conn)
    {
    die('Could not connect: ' . mysql_error());
    }
  
  ?&gt;";
  
  $host = "mail.server.com";
  $username = "username";
  $password = "password";
  
  $headers = array ('From' =&gt; $from,
    'To' =&gt; $to,
    'CC' =&gt; $cc,
    'Subject' =&gt; $subject);
  $smtp = Mail::factory('smtp',
    array ('host' =&gt; $host,
      'auth' =&gt; true,
      'username' =&gt; $username,
      'password' =&gt; $password));
  
  $mail = $smtp-&gt;send($to, $headers, $body);
  
  if (PEAR::isError($mail)) {
    echo("&lt;p&gt;" . $mail-&gt;getMessage() . "&lt;/p&gt;");
   } else {
    echo("&lt;p&gt;Message successfully sent!&lt;/p&gt;");
   }
  ?&gt;
  </code></pre>
  
  <p>MySQL schema:   </p>
  
  <pre><code>`CREATE TABLE IF NOT EXISTS `inspection` (
    `id` int(6) NOT NULL AUTO_INCREMENT,
    `vehicle` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
    `last_date` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
    `due_date` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
    PRIMARY KEY (`id`),
    KEY `vehicle` (`vehicle`,`last_date`,`due_date`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;`
  </code></pre>