2016-07-11 3 views
1

누군가가 페이지에 들어 왔을 때 전자 메일을 보내려고합니다. 페이팔 결제 확인을위한 것입니다. 당신은 무언가를 지불하고 당신이 본 것을 보았던 페이지에서 이메일이 자동 전송됩니다.PHPMAILER SERVER -> SMTP 오류 : 암호 명령 실패 SMTP 연결() 실패

function send_email($from, $to, $subject, $nombre,$apellido) {   

     $pagoReal = $_SESSION["Payment_Amount"]; 
     $monedaReal = $_SESSION["currencyCodeType"]; 
     $estado = $_SESSION['estado']; 
     $id = $_SESSION['idHash']; 



     $mail = new PHPMailer(); 
     $mail->SMTPDebug=3; 
     $mail->IsSMTP(); 
     $mail->Host = 'localhost'; 
     $mail->CharSet = "UTF-8"; 

     $mail->From = $from; 
     $mail->FromName = 'Notificación de pago via Paypal'; 
     $mail->addAddress($to); 

     $mail->WordWrap = 50; 
     $mail->IsHTML(true); 
     $mail->SMTPAuth = true; 



     $contenido = "<html><body> 
        <p>Han realizado un nuevo ingreso via Paypal</p><br> 
        Nombre del cliente: $nombre $apellido<br> 
        Cantidad que pagó: $pagoReal $monedaReal <br> 
        Estado de la reserva:$estado <br> 
        Enlace a la factura : href='xxxxx/$id<br> 
        </body></html>"; 


     $mail->Subject = $subject; 
     $mail->Body = $contenido; 

     ['tmp_name'],$_FILES['cv_contacto']['name']); 



     if (!$mail->Send()) { 
      echo 'Error enviando mensaje.'; 
      echo 'Mailer Error: ' . $mail->ErrorInfo; 

      return "Mailer Error: " . $mail->ErrorInfo; 
     } else { 
      return 1; 
     } 

    } 

그때 내가 기능

send_email('[email protected]', '[email protected]','Payment of '. $firstName." ".$lastName,$firstName,$lastName); 

에게 전화 그리고

는 오류이 오류를 얻을 :

코드는 옆에 인증이 실패 : 일반 오류를 2016년 7월 11일 14:20:51 SMTP 오류 : 암호 명령 실패 : 535 5.7.8 오류 : 인증 실패 : 일반 오류 2016-07-11 14:20:51 클라이언트 -> 서버 : 종료 2016-07-11 14:20:51 서버 -> CLIENT : 221 2.0.0 Bye 2016-07- 11 14:20:51 연결 : 닫음 2016-07-11 14:20:51 SMTP connect()가 실패했습니다. Error enviando mensaje.Mailer Error : SMTP connect()가 실패했습니다.

무엇을 할 수 있습니까?

감사합니다.

+0

시도'$ 메일 -> SMTPAuth = 거짓;'대신 사실의 로컬 서버는 메일을 릴레이하게됩니다. – drew010

+0

감사합니다 !!! – franwebofrito

+0

고맙기는하지만 PHPMailer의 이전 버전을 사용하고 있으며 사용하지 않는 예제에 코드를 기반으로했습니다. [최신 정보 얻기] (http://phpmailer.github.io/PHPMailer). – Synchro

답변

1

다음 단계를 따르십시오.

가 다음 단계를 따라주십시오 :

1) 먼저 최신 PHPmailer 파일을 다운로드

Use an App Password: If you use 2-Step Verification, try signing in with an App Password.

Allow less secure apps: If you don't use 2-Step Verification, you might need to allow less secure apps to access your account.

If you recently changed your Gmail password, you might need to re-enter your Gmail account information or completely repeat your Gmail account setup on your other email client. If the tips above didn't help, visit https://www.google.com/accounts/DisplayUnlockCaptcha and follow the steps on the page. If you use Gmail through your work, school, or other organization, visit https://www.google.com/a/yourdomain.com/UnlockCaptcha and replace yourdomain.com with your domain name.

0

은 내가이 문제를 해결했다. https://github.com/PHPMailer/PHPMailer

a) Check its there at all (on terminal) 

    ping smtp.gmail.com 

    This should give you something like this: 

    Trying 173.194.67.109... 
    Connected to gmail-smtp-msa.l.google.com. 
    Escape character is '^]'. 
    220 mx.google.com ESMTP ex2sm16805587wjd.30 - gsmtp 

b) openssl s_client -starttls smtp -crlf -connect smtp.gmail.com:587 

    You should expect a response like this: 

    Start Time: 1460541074 
    Timeout : 300 (sec) 
    Verify return code: 0 (ok) 
    --- 
    250 SMTPUTF8 

    Notice that the verify return code is 0, which indicates successful verification. 

    refer link : https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting 

2) 구글은 현재 보안 수준이 낮은 앱에서 로그인을 허용하지 않습니다.
링크 열기 : https://myaccount.google.com/security

 Firstly login your gmail account. 

    a)Scroll to the bottom and turn ON "Allow less secure apps: ON". 

    b)Now when you add the SMTP details to "Send as" google will accept them. 
    c)You need to do this for the email ID you are adding in your Send as section. 

3) 스크립트 코드 : 나는 그것의 작동 벌금을 희망

  require 'PHPMailerAutoload.php'; 


      $mail = new PHPMailer(); 

      $mail->isSMTP();      // telling the class to use SMTP 
      $mail->SMTPDebug = 2;     
      // 0 = no output, 1 = errors and messages, 2 = messages only. 

      $mail->SMTPAuth = true;    // enable SMTP authentication 
      $mail->SMTPSecure = "tls";    // sets the prefix to the servier 
      $mail->Host = "smtp.gmail.com";  // sets Gmail as the SMTP server 
      $mail->Port = 587;      // set the SMTP port for the GMAIL 

      $mail->Username = "[email protected]"; // Gmail username 
      $mail->Password = "********";  // Gmail password 

      $mail->CharSet = 'windows-1250'; 
      $mail->SetFrom ('[email protected]'); // send to mail 
      $mail->AddBCC ('[email protected]'); // send to mail 
      $mail->Subject = $subject; 
      $mail->ContentType = 'text/plain'; 
      $mail->isHTML(false); 

      $body_of_your_email ="Hello Pradeep"; 
      $mail->Body = $body_of_your_email; 
      // you may also use $mail->Body =  file_get_contents('your_mail_template.html'); 
      $mail->AddAddress ('[email protected]', 'Recipients Name');  
      // you may also use this format $mail->AddAddress ($recipient); 

      if(!$mail->Send()) 
      { 
       echo $error_message = "Mailer Error: " . $mail->ErrorInfo; 
      } else 
      { 
      echo $error_message = "Successfully sent!"; 
      } 

.

감사