2017-05-15 3 views
-1

정말 도움을받을 수 있기를 바랍니다. 나는 이것으로 약 2 시간 동안 머리카락을 꺼내왔다. 내 고객의 이메일 서버에있는 계정 중 하나가 손상되어 Google에서 이메일을 보내려고 시도하는 것을 차단하기 시작합니다. 그래서 기본 PHP 메일 명령에서 PHPMailer로 전환하고 Google의 SMTP 서버를 통해 보내려고합니다. 이 고객은 모든 계정에 대해 Google Pro를 사용합니다.Google SMTP를 통해 PHPMailer를 사용하는 PHP 메일

나는 다음과 같은 사용하고 있습니다 :

$mail    = new PHPMailer(); 

    $mail->isSMTP(); // telling the class to use SMTP 
    $mail->SMTPDebug = 1;      // enables SMTP debug information (for testing) 
    $mail->Host  = "smtp.gmail.com";  // sets GMAIL as the SMTP server 
    $mail->SMTPSecure = "tls";     // sets the prefix to the server 
    $mail->SMTPAuth = true;     // enable SMTP authentication 
    $mail->Port  = 587;     // set the SMTP port for the GMAIL server 
    $mail->Username = "[email protected]"; // GMAIL username 
    $mail->Password = "*********";   // GMAIL password 

    $mail->SetFrom('[email protected]', 'Jimmy'); 

    $mail->Subject = $this->subject; 

    $body    = $this->message; 
    //$body    = eregi_replace("[\]",'',$body);   

    $mail->MsgHTML($body); 

    $mail->AddAddress($this->to, 'bob'); 

    if(!$mail->Send()) { 
     error_log("Mailer Error: " . $mail->ErrorInfo); 
     echo '[br /]Fail'; 
    } else { 
     error_log("Message sent!"); 
     echo '[br /]Pass'; 
    } 

나는 내가 그들로 로그인 할 수 있기 때문에 자격 증명이 올바른지 알고있다. 나는이 스크립트에 물건의 모든 종류를 한 적이하고 사용하려고하는 계정이 보내 : TLS에서

  1. 변경 계정
  2. 장애인 2 팩터 인증에
  3. '차단 해제 보안 문자를'SSL하기
  4. 은 '보안 수준이 낮은 앱'는

내가 할 다른 모르겠어요 활성화 (그것은 이미 꺼져 있었다). 다음과 같이 계속 오류가 발생합니다.

2017-05-15 03:12:30 CLIENT -> SERVER: EHLO americanbeautytools.com 
2017-05-15 03:12:30 CLIENT -> SERVER: STARTTLS 
2017-05-15 03:12:30 CLIENT -> SERVER: EHLO americanbeautytools.com 
2017-05-15 03:12:30 CLIENT -> SERVER: AUTH LOGIN 
2017-05-15 03:12:30 CLIENT -> SERVER: xxx= 
2017-05-15 03:12:30 CLIENT -> SERVER: xxx= 
2017-05-15 03:12:32 SMTP ERROR: Password command failed: 535 Incorrect authentication data 
2017-05-15 03:12:32 SMTP Error: Could not authenticate. 
2017-05-15 03:12:32 CLIENT -> SERVER: QUIT 
2017-05-15 03:12:32 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting 

암호 명령에 대한 부분이 실패했습니다. 그 이메일 계정으로 로그인 할 때 어떻게 잘못 될 수 있습니까?

나는이 주제에 관한 스레드 중 약 15 개를 보았으며 제안한 것이 내 문제를 해결하지 못했습니다. 이것은 내 고객이 google을 통해 실행하는 google pro 계정이므로 '무료'제한 사항이 아닙니다.

+0

거의 * 당신은 *와 * 문제 해결 가이드, 볼 수있는 스레드의 모든 일 *는 ** 당신은 **'SMTPDebug = 2' 설정 말할 것이다. 이 값을 1로 설정하면 서버에서 말하는 내용을 볼 수 없습니다. – Synchro

+0

PHPMailer와 함께 제공되는 Gmail 예제를 기반으로 코드를 만들었 으면 처음부터 이러한 어려움을 겪지 않았을 것입니다. – Synchro

+0

@ 싱크로 - 2로 설정 했으므로 유용한 정보가 더 이상 제공되지 않았습니다. 두 번째 댓글은 도움이되지 않습니다. 내 코드를 PHPMailer 예제와 많은 변형으로 미러링했으며 오류가 남아 있습니다. 이 설정으로 끝났습니다. 외부 메일 공급자로 전환 중입니다. –

답변

-1

G- 스위트 계정 또는 sendgrid 계정으로 테스트하십시오. 작동하는 Gmail 자격 증명으로 테스트했습니다.

$mail = new PHPMailer; 
$mail->isSMTP(); 
$mail->Host = 'smtp.gmail.com'; 
$mail->Port = 465; 
$mail->SMTPSecure = 'ssl'; 
$mail->SMTPAuth = true; 
$mail->Username = '[email protected]'; // SMTP username 
$mail->Password = '123456789'; // SMTP password 
$mail->setFrom('[email protected], 'Krishna'); 
$mail->addAddress($to_addr, 'Test');  // Add a recipient 
$mail->Subject = $subject; 
$mail->isHTML(true); 
$mail->Body = $message; 
+0

질문에 답하는 방법을 설명하지 않은 채 코드를 게시하지 마십시오. – Synchro

+0

@Synchro 여기에 게시 할 답변이 없으면 제안하지 마십시오. –

+0

포스터가 충분한 정보를 제공하지 않아이 질문에 답할 수 없습니다. 고정되어 있으면 대답 할 수 있습니다. 뜻있는 시간에 당신과는 달리 나는 추측을 대답으로 게시하지 않습니다. – Synchro

-1
<?php 

     require ('../PHPMailerAutoload.php'); //add PhPMailerAutoload.php file Path 
     $mail = new PHPMailer(); // create Object 

     $name=$_POST['Name']; //get name from post method 
     $to=$_POST['email']; //get email from post method 
     $message = $_POST['message']; //get msg from post method 

     $mail->isSMTP(); // telling the class to use SMTP 
     $mail->SMTPDebug = 2;      // enables SMTP debug information (for testing) 
     $mail->Host  = "smtp.gmail.com";  // sets GMAIL as the SMTP server 
     $mail->SMTPSecure = "ssl";     // sets the prefix to the server 
     $mail->SMTPAuth = true;     // enable SMTP authentication 
     $mail->Port  = 465;     // set the SMTP port for the GMAIL server 
     $mail->Username = "[email protected]"; // GMAIL username 
     $mail->Password = "*********";   // GMAIL password 
     $mail->SetFrom('[email protected]', 'Jimmy'); //Set who the message is to be sent from 
     $mail->Subject = "Email from Mailer"; // $this->subject; 
     $mail->Body = "test Email msg";  // $this->message; 
     $mail->isHTML(true); 
     $mail->MsgHTML($message); 
     $mail->addAddress($to,$name); 
     $mail->WordWrap = 70; 

     if(!$mail->Send()) { 
      echo 'Message could not be sent.'.'<br>'; 
      echo "Mailer Error: " . $mail->ErrorInfo); 
      exit; 

     } else { 
      echo 'Message sent.'.'<br>'; 
      exit; 
     } 


    ?> 
+0

주석 처리되지 않은 코드는 게시하지 마십시오. – Synchro

관련 문제