Php 每天使用自动加载功能发送电子邮件不起作用

Php 每天使用自动加载功能发送电子邮件不起作用,php,class,pdo,autoload,Php,Class,Pdo,Autoload,我想每天从我的数据库向用户发送电子邮件。查询将检查今天的日期是否大于创建日期,以及状态是否等于打开。我正在使用uu autoload调用这个查询所在的类。请帮助我如何使它工作。谢谢 更新------------------------------------------ function __autoload($class_name) { require 'EmailNotif.php'; } $class = new EmailNotif(); 我尝试使用此选项,但收到消息:无法

我想每天从我的数据库向用户发送电子邮件。查询将检查今天的日期是否大于创建日期,以及状态是否等于打开。我正在使用uu autoload调用这个查询所在的类。请帮助我如何使它工作。谢谢

更新------------------------------------------

function __autoload($class_name) {

    require 'EmailNotif.php';
}

$class = new EmailNotif();
我尝试使用此选项,但收到消息:无法加载EmailNotif。

function __autoload($class_name) {

   if(file_exists($class_name . '.php')) {
      require_once($class_name . '.php');    
   } else {
      throw new Exception("Unable to load $class_name.");
   }
}

try {
   $class = new EmailNotif();
} catch (Exception $e) {
   echo $e->getMessage(), "\n";
}
结束更新-----------------------------------------------

function __autoload($class_name) {

    require 'EmailNotif.php';
}

$class = new EmailNotif();
EmailNotif.php

class EmailNotif {

   function email() {

    $date = date('Y-m-d');
    $stats = 'Open';

   $conn = dbConnect();
   $stmt = $conn->prepare("SELECT * FROM invalid_invoice WHERE Creation_Date<=:date AND Status=:stats");
   $stmt->bindParam(':date', $date);
    $stmt->bindParam(':stats', $stats);
   $stmt->execute();
   $data = $stmt->fetchAll(PDO::FETCH_ASSOC);
   $conn = null;
   //var_dump($data);


   $messages = array();

   foreach ($data as $row6) {

            $invnumb=$row6['Invoice_Number'];
            $partnumb=$row6['Part_Number'];
            $issue=$row6['Issues'];
            $pic=$row6['PIC_Comments'];
            $issuetype=$row6['Issue_Type'];
            $createdate=$row6['Creation_Date'];
            $site=$row6['Site'];
            $vendor=$row6['Vendor_Name'];
            $invdate=$row6['Invoice_Date'];
            $po=$row6['PO'];
            $rr=$row6['RR'];
            $currency=$row6['Currency'];
            $invamount=$row6['Invoice_Amount'];
            $stat=$row6['Status'];
            $emailadd= $row6['PersoninCharge'];


    if(!isset($messages[$emailadd])) {

                $messages[$emailadd] = '';
        }

                $messages[$emailadd] .= "<b>Issue Type: {$issuetype} </b><br><br>";
                $messages[$emailadd] .= "<b>Creation Date: {$createdate} </b><br><br>";
                $messages[$emailadd] .= "<b>Site: {$site} </b><br><br>";
                $messages[$emailadd] .= "<b>Vendor Name: {$vendor} </b><br><br>";
                $messages[$emailadd] .= "<b>Invoice Date: {$invdate} </b><br><br>";
                $messages[$emailadd] .= "<b>Invoice Number: {$invnumb} </b><br><br>";
                $messages[$emailadd] .= "<b>Part Number:</b><br>{$partnumb}<br><br>";
                $messages[$emailadd] .= "<b>PO: {$po} </b><br><br>";
                $messages[$emailadd] .= "<b>RR: {$rr} </b><br><br>";
                $messages[$emailadd] .= "<b>Currency: {$currency} </b><br><br>";
                $messages[$emailadd] .= "<b>Invoice Amount: {$invamount} </b><br><br>";
                $messages[$emailadd] .= "<b>Issues:{$issue}</b><br><br>";
                $messages[$emailadd] .= "<b>Status: {$stat} </b><br><br>";
                $messages[$emailadd] .= "<b>PIC Comments: {$pic}</b><br>";
                $messages[$emailadd] .= "<br><br>";

   }

   foreach($messages as $email=>$message) {

      $send_to = $email;
      $subject = "Invalid Invoice Tracking Message";
      $message = "<html>{$message}</html>";

      $sql7 = "INSERT INTO email_queue (send_to, subject, message) 
        VALUES (:send_to, :subject, :message)"; 

      $conn = dbConnect();
      $stmt7 = $conn->prepare($sql7); 
      $stmt7->bindParam(':send_to', $send_to);
      $stmt7->bindParam(':subject', $subject);
      $stmt7->bindParam(':message', $message);
      $stmt7->execute();
      $conn=null; 

   }

  }
  }
classemailnotif{
功能电子邮件(){
$date=日期('Y-m-d');
$stats=‘打开’;
$conn=dbConnect();

$stmt=$conn->prepare(“从创建时无效的发票中选择*)\u DateHaha@Fred ii-我没有注意到。但仍然不工作:(您的调试发现哪个部分有故障?--@Dagon请查看上面的更新