2016-07-11 17 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 Connection:closed 2016-07-11 14:20:51 SMTP connect()に失敗しました。 Error enviando mensaje.Mailer Error:SMTP connect()が失敗しました。

何ができますか?

ありがとうございます!

+0

ローカルサーバーでメールを中継させる場合は、trueの代わりに '$ mail-> SMTPAuth = false;'を試してください。 – drew010

+0

感謝しています! – franwebofrito

+0

これを修正してうれしいですが、古いバージョンのPHPMailerを使用していて、あなたのコードを古くなった例に基づいています。 [最新情報を入手する](http://phpmailer.github.io/PHPMailer) – Synchro

答えて

1

この手順に従ってください。

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

私はこの問題を解決しています

以下の手順に従ってください:まず最新phpmailerのファイルをダウンロード

1)。 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)Googleは今、安全性の低いアプリのからのログインを許可していません。
オープンリンク: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 = "pradee[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!"; 
      } 

私はその作業罰金を願っています。

ありがとう

関連する問題