2014-12-21 2 views
1

phpmailer 클래스를 사용하여 php에서 이메일을 보내고 테스트 해 보았습니다. 내 설정은 다음과 같습니다 :phpmailer가 Gmail에서 작동하지 않습니다

require '../php/library/class.phpmailer.php'; 
require '../php/library/class.smtp.php'; 

$mail = new PHPMailer; 

$mail->isSMTP(); 

$mail->SMTPDebug = 2; 

$mail->Debugoutput = 'html'; 

$mail->Host = 'smtp.gmail.com'; 

$mail->Port = 587; 

$mail->SMTPSecure = 'ssl'; 

$mail->SMTPAuth = true; 

$mail->Username = "[email protected]"; 

$mail->Password = "thepassword"; 

$mail->setFrom('[email protected]', 'Real Name'); 

$mail->addAddress($validEmail); 

$mail->Subject = 'Confirmation Code'; 

$mail->msgHTML('Follow this link: <a href="http://test.com/confirm?code=' . $newAccount->confirmationCode . '">http://test.com/confirm?code=' . $newAccount->confirmationCode . '</a>'); 

$mail->AltBody = 'This is a plain-text message body with this link: http://test.com/confirm?code=' . $newAccount->confirmationCode; 

if (!$mail->send()) { 
    echo "Mailer Error: " . $mail->ErrorInfo; 
} 

그러나 작동하지 않는 것 같아서 Gmail 예제에서 코드를 붙여 넣습니다. 나는 에러 출력을 위해 월드 와이드 웹을 검색했다 :

SMTP ERROR: Failed to connect to server: php_network_getaddresses: getaddrinfo failed: Name or service not known (0) 
SMTP connect() failed. 
Mailer Error: SMTP connect() failed. 

그러나 여전히 잘못된 것을 찾을 수 없다. 어떤 도움을 주시겠습니까?

UPDATE은 내가 phpmailer보다는 당신이 사용했던 예전의 코드와 함께 제공되는 Gmail은 예제 코드로 시작해보십시오 Gmail은

+0

여기 내 의견과 같은 phpmailer에 정확하게하지 않은 문제 해결 가이드를 확인하십시오. 필자는 Mantis 메일러 시스템이 phpmailer를 사용하고 있으며 10 월 이후 동일한 문제에 직면하고 있음을 인정해야합니다. 내 서버에서는 구성이 변경되지 않았지만 전자 메일 알림은 더 이상 전송되지 않습니다. – Greg0ry

+0

유닉스 서버입니까? – ksealey

+0

@ksealey fedora core 20 – Klimid1689

답변

관련 문제