2015-01-28 1 views
3

여기 거의 일주일 동안 붙어 있습니다. 실제로 튜토리얼의 단계를 따라 갔지만 운이 없었습니다. 이 phpmailer을 다운로드하고 버전 5.4.2를 얻었습니다. 아래의 코드는이 다운로드 된 phpmailer의 예이지만 나에게는 적합하지 않습니다. 이미 sendmailphp.ini를 구성했습니다. 나는 또한 와 같은 몇몇 연장을 가능하게했다 openssl 그리고 phpsocket php smtp아파치 단위. 누군가가이 문제로 나를 도울 수 있기를 바랍니다. 다음은 내 코드입니다.SMTP -> ERROR : 서버에 연결하지 못했습니다. 다음 보낸 사람 주소가 실패했습니다. : 연결되지 않은 상태에서 Mail()을 호출했습니다. 메일러 오류

<html> 
<head> 
<title>PHPMailer - SMTP (Gmail) basic test</title> 
</head> 
<body> 

<?php 

error_reporting(E_STRICT); 

date_default_timezone_set('America/Toronto'); 

require_once('../class.phpmailer.php'); 
class.phpmailer.php if not already loaded 

$mail    = new PHPMailer(); 

$body    = "dasdf"; 

$mail->IsSMTP(); // telling the class to use SMTP 
$mail->Host  = "mail.yourdomain.com"; // SMTP server 
$mail->SMTPDebug = 2;      // enables SMTP debug information (for testing) 
             // 1 = errors and messages 
             // 2 = messages only 
$mail->SMTPAuth = true;     // enable SMTP authentication 
$mail->SMTPSecure = "ssl";     // sets the prefix to the servier 
$mail->Host  = "smtp.gmail.com";  // sets GMAIL as the SMTP server 
$mail->Port  = 465;     // set the SMTP port for the GMAIL server 
$mail->Username = "[email protected]"; // GMAIL username 
$mail->Password = "ggg";   // GMAIL password 

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

$mail->AddReplyTo("[email protected]","jj"); 

$mail->Subject = "PHPMailer Test Subject via smtp (Gmail), basic"; 

$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test 

$mail->MsgHTML($body); 

$address = "[email protected]"; 
$mail->AddAddress($address, "Dave"); 

$mail->AddAttachment("images/phpmailer.gif");  // attachment 
$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment 

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

?> 

</body> 
</html> 
+0

을 추가하여 SMTP 디버깅을 사용한다'$ 메일 -> Host' 두 번 정의했다. 그게 아무것도 영향을 미치지 않거나 첫 번째 항목을 덮어 쓰는 것인지 확실하지 않습니다. 또한 첨부 파일을 제거하고 전송하는지 확인합니다. 그 외에는 어떤 문제도 보이지 않습니다. – Devon

+1

켈빈이 말하는 것을하십시오. [this example] (https://github.com/PHPMailer/PHPMailer/blob/master/examples/gmail.phps)을 시작점으로 사용해야합니다. 또한 Gmail의 최근에 변경된 인증 정책에 대한 참고 사항을 참조하십시오 (https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting). – Synchro

답변

2

그 버전의 PHPMailer는 매우 오래되었습니다. (2010 년 2 월 업데이트); https://github.com/PHPMailer/PHPMailer

다른 어떤 것보다 먼저 최신 버전으로 업그레이드해야합니다. 이미 수정 된 버그를 해결하려고 할 가능성이 큽니다.

사용법은 거의 동일합니다. GitHub 페이지의 예제에서 현재 버전과의 명백한 차이점을 확인하십시오.

당신은 또한 당신이

$mail->SMTPDebug = 3; 
+1

Spot-on Kelvin, 감사합니다. – Synchro

관련 문제