Class 'PHPMailer\PHPMailer\Exception' 未找到

Class 'PHPMailer\\PHPMailer\\Exception' not found

使用 PHP 邮件程序版本 6.0.6

我知道类似的问题得到了回答,但我的情况不同。 我已经成功配置了它运行良好的脚本;我正在接收邮件,然后突然间我这边没有任何更改就开始抛出这个错误。

错误

    [Sun Nov 25 21:49:37.852920 2018] [:error] [pid 2060:tid 780] [client ::1:59300] 
   PHP Fatal error:  Uncaught Error: Class 'PHPMailer\PHPMailer\Exception' not found in   E:\TCi\htdocs\sdresidency\website\plugins\PHPMailer\PHPMailer.php:1920\nStack trace:\n#0  E:\TCi\htdocs\sdresidency\website\plugins\PHPMailer\PHPMailer.php(1774): PHPMailer\PHPMailer\PHPMailer->smtpConnect(Array)\n#1   E:\TCi\htdocs\sdresidency\website\plugins\PHPMailer\PHPMailer.php(1516): PHPMailer\PHPMailer\PHPMailer->smtpSend('Date: Sun, 25 N...', 'This is a multi...')\n#2 
E:\TCi\htdocs\sdresidency\website\plugins\PHPMailer\PHPMailer.php(1352): PHPMailer\PHPMailer\PHPMailer->postSend()\n#3  
E:\TCi\htdocs\sdresidency\website\newbooking.php(38): PHPMailer\PHPMailer\PHPMailer->send()\n#4 {main}\n  thrown in 

这是我用来发送邮件的配置

require_once "plugins/PHPMailer/PHPMailer.php";
        require_once "plugins/PHPMailer/SMTP.php";
        $mail = new PHPMailer\PHPMailer\PHPMailer();
    $mail->IsSMTP(); // enable SMTP



    //Enable SMTP debugging. 
    $mail->SMTPDebug = 0;  // debugging: 1 = errors and messages, 2 = messages only                             
    //Set PHPMailer to use SMTP.
    $mail->IsSMTP(); // enable SMTP          
    //Set SMTP host name                          
    $mail->Host = "md-in-30.webhostbox.net";
    //Set this to true if SMTP host requires authentication to send email
    $mail->SMTPAuth = true;                          
    //Provide username and password     
    $mail->Username = "<my mail id>";                 
    $mail->Password = "<my password>";                           
    //If SMTP requires TLS encryption then set it
    $mail->SMTPSecure = "tls";                           
    //Set TCP port to connect to 
    $mail->Port = 587;                                   

    $mail->From = "<my mail id>";
    $mail->FromName = "SD RESIDENCY";
    $mail->addAddress("<receive mail id>", "name");
    $mail->isHTML(true);
    $mail->Subject = "NEW RESERVATION";
    $mail->Body = $message;
    $mail->AltBody = "No HTML Support";

    if(!$mail->send()) 
    {    $_SESSION['message'] = 'SOME ERROR OCCURED, PLEASE TRY AGAIN';} 
    else 
    {    
        $_SESSION['message'] = 'BOOKING COMPLETED SUCCESSFULLY';
        header("Location: " . $_SERVER["HTTP_REFERER"]);

    }

我将 html 格式的邮件内容存储在 $message 变量中。 我已经在堆栈和其他站点中尝试了所有已回答的问题,但没有成功;任何帮助将不胜感激

  1. 尝试将require_once "plugins/PHPMailer/PHPMailer.php";替换为

require_once "./plugins/PHPMailer/PHPMailer.php";

  1. 不要直接包含库。使用作曲家进行自动加载
    1. 安装 Composer https://getcomposer.org/download/
    2. 通过 Composer 安装 PHP Mailer。在控制台上输入 composer require phpmailer/phpmailer https://packagist.org/packages/phpmailer/phpmailer
    3. 在 php 文件中包含 Composer 的自动加载器。 require 'vendor/autoload.php';
    4. 利润。您可以很容易地包含和使用 PHP Mailer 和其他库