2017-04-11 1 views
-1

내 문제를 해결하기 위해 여러 시간 동안 검색했지만 실패했습니다.메일러 오류로 인해 오류 발생 : SMTP connect()가 실패했습니다.

이 XAMPP에 Gmail으로 이메일을 보내이 오류 때마다 얻을 수 PHPMailer 내 간단한 코드를 사용 입니다 :

Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

을이 내 PHP 코드입니다 :

<?php 
require_once('PHPMailer/PHPMailerAutoload.php'); 

$mail = new PHPMailer(); 
$mail->isSMTP(); 
$mail->SMTPAuth = true; 
$mail->SMTPSecure = 'ssl'; 
$mail->HOST = 'smtp.gmail.com'; 
$mail->PORT = '465'; 
$mail->isHTML(); 
$mail->Username = '##myemail##@gmail.com'; 
$mail->Password = '##mypass##'; 
$mail->SetFrom('[email protected]'); 
$mail->Subject = 'Hello World'; 
$mail->Body = 'A test email!'; 
$mail->AddAddress('[email protected]'); 


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

?> 

도와주세요.

+1

위키를 확인 했습니까? https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting#smtp-error-could-not-connect-to-smtp-host – modsfabio

+0

아마도 당신은 인증 오류가 있지만'$ mail-> SMTPDebug = 2 '오류를 알려주십시오. – Linek

+1

[PHPMailer, SMTP connect()에서 Gmail에 오류가 발생했습니다.] (http://stackoverflow.com/questions/25924651/phpmailer-smtp-connect-failed-error-with-gmail) – Synchro

답변

0

출력을 디버그하려면이 $mail->SMTPDebug = 3; $mail->isHTML(true);을 추가하십시오. Gmail을 사용하는 안전하지 않은 앱으로 연결을 활성화했는지 확인하십시오. 이 링크를 찾으십시오 https://support.google.com/a/answer/6260879?hl=en

관련 문제