2016-09-12 2 views
-1

이 오류가 발생하는 이유는 무엇입니까? PHPMailer Mail Error - >SMTP connect(). 어떻게 해결할 수 있습니까?PHPMailer 메일 오류 -> SMTP connect()

$mail->SMTPSecure = "ssl"; 

하려면 :

$mail->SMTPSecure = "tls"; 

A I 내가 PHP

<?php 
    require '../plugins/phpmailer/PHPMailerAutoload.php'; 
    $mail = new PHPMailer(); 
    $mail->CharSet = "utf-8"; 
    $mail->IsSMTP(); 
    $mail->SMTPDebug = 1; 
    $mail->SMTPAuth = true; 
    $mail->Username = "[email protected]"; 
    $mail->Password = "mypass"; 
    $mail->SMTPSecure = "ssl"; 
    $mail->Host = "smtp.gmail.com"; 
    $mail->Port = "587"; 

    $mail->setFrom('[email protected]', 'your name'); 
    $mail->AddAddress('[email protected]', 'receivers name'); 

    $mail->Subject = 'using PHPMailer'; 
    $mail->IsHTML(true); 
    $mail->Body = 'Hi there , 
          <br /> 
          this mail was sent using PHPMailer... 
          <br /> 
          cheers... :)'; 

    if ($mail->Send()) { 
     echo "Message was Successfully Send :)"; 
    } else { 
     echo "Mail Error - >" . $mail->ErrorInfo; 
    } 
    ?> 
+0

사용자 이름이/암호가 정확하지 아니면 Gmail에서 메일을 릴레이에 연결할 수 있도록 준비가되어 있지 않기 때문에 나는 그것이 기대 :

// $mail->IsSMTP(); 

아래에 노력하고 데모를 참조하십시오. 오류가 더 자세한 정보를 제공합니까? 그렇지 않다면 코드에서 오류를 찾아서 –

+0

사용자 이름과 암호를 확인하는 것이 좋습니다. gmail에서 보안에 관한 메일을받습니다. – Pides1937

+0

그건 내 완벽한 오류입니다 : 2016-09-12 07:35:18 \t SMTP 오류 : 서버에 연결하지 못했습니다 : (0) 2016-09-12 07:35:18 \t SMTP connect()가 실패했습니다. https://github.com/PHPMailer/PHPMailer/wiki/ 메일 문제 해결 -> SMTP connect()에 실패했습니다. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting – Pides1937

답변

1

SMTP 연결에 의한 오류가 발생했습니다. 구성을 먼저 확인하고 $ mail-> IsSMTP(); 줄을 주석으로 확인할 수 있습니다.

<?php 
    require 'phpmailer.php'; 
    require 'smtp.php'; 
    $mail = new PHPMailer; 
    //$mail->IsSMTP(); // telling the class to use SMTP 
    $mail->Host  = "smtp.gmail.com"; // SMTP server 
    $mail->SMTPDebug = 1;      // enables SMTP debug information (for testing) 
             // 1 = errors and messages 
             // 2 = messages only 
    $mail->SMTPAuth = true;     // enable SMTP authentication 
    $mail->Host  = "smtp.gmail.com"; // sets the SMTP server 
    $mail->Port  = 465;     // set the SMTP port for the GMAIL server 
    $mail->Username = GMAIL EMAIL ID; // SMTP account username 
    $mail->Password = GMAIL PASSWORD;  // SMTP account password 
    $mail->SMTPSecure = 'ssl'; 


    $mail->From = '[email protected]'; 
    $mail->FromName = 'Mailer'; 
    $mail->addAddress('MAIL ID to whom you eant to send');    // Name is optional 

    $mail->addCC('CC EMAIL ID'); 
    $mail->addBCC('BCC EMAIL ID'); 
    $mail->WordWrap = 50;         // Set word wrap to 50 characters 

    $mail->Subject = 'Here is the subject'; 
    $mail->Body = 'MESSAGE'; 
    $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; 

    if(!$mail->send()) { 
    echo 'Message could not be sent.'; 
    echo 'Mailer Error: ' . $mail->ErrorInfo; 
    } else { 
    echo 'Message has been sent'; 
} 
    ?> 
+0

'smtp.php'파일이 있습니다. PHPMailerAutoload.php 만 가지고 있습니다. – Pides1937

+0

isSMTP 라인에 댓글을 달았습니다. 메시지 : Message was Successfully Send :) ...하지만받은 편지함에 아무것도 가지고 있지 않다. – Pides1937

+0

그래서 그 파일은 smtp 클래스와 그 메소드를 가질 수 있으므로 smtp.php를 추가 할 필요가 없다. –

0

당신의 라인을 변경하여 새로운 해요, 내가 정확히 explications을 필요로 할 수있는 방법에 대해 어떤 생각을 가지고 있지 않습니다 많은 보안 문제가있어 많은 메일 서버가 SSL을 더 이상 허용하지 않습니다.

+0

got 새로운 오류 : 2016-09-12 07:43:54 \t 클라이언트 -> 서버 : EHLO occ.webpage.com 2016-09-12 07:43:54 \t 클라이언트 -> 서버 : STARTTLS 2016-09-12 07:43 : 55 \t 클라이언트 -> 서버 : EHLO occ.diosoftmobile.com 2016-09-12 07:43:55 \t 클라이언트 -> 서버 : 사용자 로그인 2016 클라이언트 -> 서버 : YmFjaXUuYWFsZXhhbmRt 2016-09-12 07:43:55 \t 클라이언트 -> 서버 : cnVwdG9TA = 2016-09-12 07:43:55 \t SMTP 오류 : 암호 명령 실패 : 535-5.7.8 사용자 이름과 암호가 허용되지 않습니다. 535에서 자세히 알아보기 5.7.8 https://support.google.com/mail/?p=BadCredentials o5sm16511065wmg.16 - gsmtp \t MTP 오류 : 인증 할 수 없습니다. 클라이언트 -> 서버 : 종료 – Pides1937

+0

귀하의 조언은 정확하지만 그 이유는 아닙니다 - SMTPS (SMTP over SSL)는 1998 년부터 사용이 중단되었으며 Microsoft에서 지원 중단을 무시하기 때문에 여전히 주위에 있습니다. 같은 해 SMTP + STARTTLS로 대체되었습니다. 내부적으로 둘 다 정확히 동일한 암호화를 사용하기 때문에 보안에는 차이가 없습니다. – Synchro

+0

@ Pides1937 - 그게 무슨 말을하는거야? – Synchro

관련 문제