我不知道為什麼會(huì)收到此「PHPMailer 未定義類型」錯(cuò)誤。首先,我嘗試直接下載zip並從github複製程式碼,同樣的問(wèn)題出現(xiàn),然後我下載了我不想下載的composer,但下載後仍然顯示相同的錯(cuò)誤。
請(qǐng)問(wèn)我可以對(duì)此有什麼想法嗎? (以下截圖)
作曲家 img 錯(cuò)誤
沒(méi)有作曲家img時(shí)出現(xiàn)同樣的錯(cuò)誤
目錄圖片
這是程式碼
session_start();
// Import PHPMailer classes into the global namespace use PHPMailerPHPMailerPHPMailer; use PHPMailerPHPMailerException; require 'PHPMailer/src/Exception.php'; require 'PHPMailer/src/PHPMailer.php'; require 'PHPMailer/src/SMTP.php'; $mail = new PHPMailer(true); // error coming here $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = 'user@gmail.com'; // SMTP username $mail->Password = 'gmail_password'; // SMTP password $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted $mail->Port = 587; // TCP port to connect to // Sender info
謝謝
當(dāng)您使用作曲家時(shí),只需要自動(dòng)載入(它完成所有「需要」工作)
include_once 'vendor/autoload.php' use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; // require 'PHPMailer/src/Exception.php';