"치명적인 오류: 'PHPMailer' 클래스를 찾을 수 없음' 문제 해결
PHPMailer 라이브러리를 활용하려고 할 때 다음과 같은 문제가 발생할 수 있습니다. 'PHPMailer' 클래스를 찾을 수 없다는 치명적인 오류가 발생했습니다. 이 문제는 PHP 스크립트에 라이브러리가 제대로 포함되지 않았을 때 발생합니다.
이 오류를 해결하려면 이전에 'include_once()'를 사용하여 'PHPMailerPHPMailerAutoload.php' 파일을 포함하려고 시도했습니다. 그러나 최근 라이브러리 업데이트에서는 자동 로드 기능이 제거되어 다른 초기화 방법이 필요합니다.
다음 코드 조각은 PHPMailer의 업데이트된 초기화 프로세스를 간략하게 설명합니다.
<?php require("/home/site/libs/PHPMailer-master/src/PHPMailer.php"); require("/home/site/libs/PHPMailer-master/src/SMTP.php"); $mail = new PHPMailer\PHPMailer\PHPMailer(); $mail->IsSMTP(); // enable SMTP $mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only $mail->SMTPAuth = true; // authentication enabled $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail $mail->Host = "smtp.gmail.com"; $mail->Port = 465; // or 587 $mail->IsHTML(true); $mail->Username = "xxxxxx"; $mail->Password = "xxxx"; $mail->SetFrom("[email protected]"); $mail->Subject = "Test"; $mail->Body = "hello"; $mail->AddAddress("[email protected]"); if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message has been sent"; } ?>
다음을 확인하세요. require() 문의 경로와 이메일 주소를 자신의 관련 정보로 바꾸십시오.
이 업데이트된 초기화 프로세스를 따르면 "치명적인 오류: 클래스" 오류가 발생하지 않고 PHPMailer 라이브러리를 성공적으로 사용할 수 있습니다. 'PHPMailer'를 찾을 수 없음' 문제.
위 내용은 PHP에서 '치명적인 오류: 'PHPMailer' 클래스를 찾을 수 없음' 문제를 해결하는 방법은 무엇입니까?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!