2017-09-05 6 views
1

이미 많은 스레드가 있다는 것을 알고 있지만 제대로 작동하지 않으며 이미 모든 것을 시도했습니다! phpmailer 다운로드에는 autoload.php가 없으며 막혀 있습니다.잡히지 않은 오류 : 'PHPMailer'클래스를 찾을 수 없습니다.

필자가 이미 필요한 파일을 링크했지만 "class 'phpmailer'not found"오류 메시지가 나타납니다. Xampp이 실행 중입니다. 모든 메일러 파일은 폴더 PHPMailer (src 폴더가 포함되어 있고 그 안에 5 개의 파일이 있습니다) 안에 있습니다. 미리 감사드립니다! 대신이의

<!--Contact Starts--> 
     <div class="container contactform center"> 
      <h2 class="text-center wowload fadeInUp"></h2> 
      <div class="row wowload fadeInLeftBig">  
        <div class="col-sm-6 col-sm-offset-3 col-xs-12"> 
        <form method="post" action="index.php"> 
        <input type="text" placeholder="Nombre" name="nombre" required> 
        <input type="email" placeholder="Email" name="email" required> 
        <input type="text" placeholder="Móvil" name="movil" required> 
        <textarea rows="5" placeholder="Mensaje" name="mensaje" required></textarea> 
        <button class="btn btn-danger" type="submit" name="sendBtn"><i class="fa fa-paper-plane"></i> Send</button> 
        </form> 
        </div> 
      </div> 
     </div> 
    </div> 
    <!--Contact Ends--> 

<?php 

if(isset($_POST["sendBtn"])){ 
    require "PHPMailer/src/PHPMailer.php"; 
    require "PHPMailer/src/OAuth.php"; 
    require "PHPMailer/src/SMTP.php"; 
    require "PHPMailer/src/POP3.php"; 
    require "PHPMailer/src/Exception.php"; 

    //Create a new PHPMailer instance 

    $mail = new PHPMailer(); 

    //Tell PHPMailer to use SMTP 

    $mail->isSMTP(); 


    //Enable SMTP debugging 

    // 0 = off (for production use) 

    // 1 = client messages 

    // 2 = client and server messages 

    $mail->SMTPDebug = 2; 



    //Set the hostname of the mail server 

    $mail->Host = 'smtp.gmail.com'; 

    // use 

    // $mail->Host = gethostbyname('smtp.gmail.com'); 

    // if your network does not support SMTP over IPv6 

    //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission 

    $mail->Port = 587; 

    //Set the encryption system to use - ssl (deprecated) or tls 

    $mail->SMTPSecure = 'tls'; 

    //Whether to use SMTP authentication 

    $mail->SMTPAuth = true; 

    //Username to use for SMTP authentication - use full email address for gmail 

    $mail->Username = "[email protected]"; 

    //Password to use for SMTP authentication 

    $mail->Password = "xxxxxx"; 

    //Set who the message is to be sent from 

    $mail->setFrom($_POST["email"], $_POST["nombre"]); 

    //Set who the message is to be sent to 

    $mail->addAddress('[email protected]', 'John Doe'); 

    //Set the subject line 

    $mail->Subject = 'PHPMailer GMail SMTP test'; 

    //Read an HTML message body from an external file, convert referenced images to embedded, 

    //convert HTML into a basic plain-text alternative body 

    $mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__)); 



    //Replace the plain text body with one created manually 

    $mail->AltBody = $_POST["mensaje"] . '<br><p Móvil: '.$_POST["movil"].'</p>'; 


    //send the message, check for errors 

    if (!$mail->send()) { 

     echo "Mailer Error: " . $mail->ErrorInfo; 

    } else { 

     echo "Message sent!"; 

    } 
} 
+1

다른 제안보다 먼저 수행 할 제안 된 정상 확인을 놓친 것처럼 보입니다. https://github.com/PHPMailer/PHPMailer/wiki/Tutorial#first-time 어쩌면 제대로 설치하지 않았을 수도 있습니다. – RiggsFolly

+1

이것은'네임 스페이스 '문제입니다.'$ mail = new PHPMailer \ PHPMailer \ PHPMailer();' – cmorrissey

+0

고맙습니다! 일 했어 !! – BabyBoy

답변

6

:

//Create a new PHPMailer instance 
$mail = new PHPMailer(); 

사용이 : 당신이 아래 링크를 http://webdevzoom.com/how-to-install-composer-on-windows/

실행이 명령을 참조 설치하려면 작곡가 를 설치해야

//Create a new PHPMailer instance 
$mail = new PHPMailer\PHPMailer\PHPMailer(); 
+1

PHPMailer의 클래스 이름을 네임 스페이스에 가져 오는 것입니다. '를 사용하여 PHPMailer \ PHPMailer \ PHPMailer; $ mail = new PHPMailer;'두 접근법은 readme에 자세히 설명되어 있습니다. – Synchro

0

당신의 cmd 폴더의 xampp 프로젝트 폴더(로컬) "작성자는 phpmailer/phpmailer 필요"

그러면 공급 업체 폴더에 자동 업로드 파일이 생성됩니다. 추가해야 할 그 후 는

가 다음 요구 사항 .. 사용 'phpmailer/phpmailer/PHPMailer'에 따라 각각의 파일을 사용 .. 당신의 위의 코드에 " '. 공급 업체/자동 업로드 PHP는'필요"; 'phpmailer/phpmailer/Exception'을 사용하십시오.