2017-11-18 3 views
0

아래의 코드는 PHP에 있습니다발견되지 phpmailer는

class Email 
{ 
    private $mail,$to,$subject,$body; 
    function __construct() 
    { 
     require_once "phpmailer1/src/PHPMailer.php"; 
     require_once "phpmailer1/src/SMTP.php"; 
     require_once "phpmailer1/src/POP3.php"; 
     $this->mail = new PHPMailer(true); 
     $this->mail->isSMTP(); 
     $this->mail->Host = "smtp.gmail.com"; 
     $this->mail->Username = "emailaddress"; 
     $this->mail->Password = "password"; 
     $this->mail->SMTPSecure = "tls"; 
     $this->mail->Port = 587; 
     $this->to = "0"; 
     $this->subject = "0"; 
     $this->body = "0"; 
     $this->mail->SMTPAuth = true; 
     $this->mail->setFrom("new address email","hello"); 
     $this->mail->CharSet = "utf-8"; 
     $this->mail->SMTPOptions = array(
     'ssl' => array(
      'verify_peer' => false, 
      'verify_peer_name' => false, 
      'allow_self_signed' => true 
     ) 
     ); 
    } 
    function ToEmail($getmail) 
    { 
     $this->to = $getmail; 
    } 
    function SubjectMail($submail) 
    { 
     $this->subject = $submail; 
    } 
    function BodyMail($bodymail) 
    { 
     $this->body = $bodymail; 
    } 
    function Send() 
    { 
     if($this->to != "0" && $this->subject != "0" && $this->body != "0") 
     { 
      $this->mail->addAddress($this->to,"hello"); 
      $this->mail->subject = $this->subject; 
      $this->mail->msgHTML($this->body); 
      if($this->mail->send()) 
      { 
       echo "Email Send"; 
      } 
      else 
      { 
       echo "Email Not Send"; 
      } 
     } 
     else 
     { 
      echo "230"; 
     } 
    } 
}; 

내가 phpmailer의 새 버전을 사용하고 싶지만 내가 그것을 실행하려고 할 때 나는

Fatal error: Uncaught Error: Class 'PHPMailer' not found in C:\xampp\htdocs\xampp\khunehyab\email\mainemail.php:13 Stack trace: #0 C:\xampp\htdocs\xampp\khunehyab\email\mainemail.php(69): Email->__construct() #1 {main} thrown in what do i do?? please help me my phpmailer is v6.0.1

+0

가능한 중복 https://stackoverflow.com/questions/44843305/how-to-integrate-phpmailer-with-codeigniter-3 – TimBrownlaw

답변

0

당신을보고 PHPMailer\PHPMailer\PHPMailer의 정규화 된 클래스 이름 (FQCN)을 사용하거나 파일 상단에 use PHPMailer\PHPMailer\PHPMailer;으로 네임 스페이스로 가져와야합니다.