2010-01-20 3 views
1

PHPMailer_V5.1을 사용하여 Gmail을 통해 이메일을 보내려고합니다.PHPMailer_v5.1을 사용하여 Gmail을 통해 이메일을 보낼 수 없습니다.

, 다음과 같은 오류

SMTP를 얻기 -> 오류 : 서버에 연결하지 못했습니다 : 소켓 전송 "SSL"를 찾을 수 없습니다 - 당신이 PHP를 구성 할 때 당신은 그것을 가능하게하는 것을 잊지 않았다? (41961176) SMTP 오류 : SMTP 호스트에 연결할 수 없습니다.

이 다음은 PHPMailer 다운로드와 함께 제공되는 코드입니다, 난 그냥

<?php 
    require_once('../class.phpmailer.php'); 
    //include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded 

    $mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch 

    $mail->IsSMTP(); // telling the class to use SMTP 

    try { 
     $mail->Host  = "mail.yourdomain.com"; // SMTP server 
     $mail->SMTPDebug = 2;      // enables SMTP debug information (for testing) 
     $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 = "********";   // GMAIL password 
     $mail->AddReplyTo('[email protected]', 'First Last'); 
     $mail->AddAddress('[email protected]', 'John Doe'); 
     $mail->SetFrom('[email protected]', 'First Last'); 
     $mail->AddReplyTo('[email protected]', 'First Last'); 
     $mail->Subject = 'PHPMailer Test Subject via mail(), advanced'; 
     $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically 
     $mail->MsgHTML(file_get_contents('contents.html')); 
     $mail->AddAttachment('images/phpmailer.gif');  // attachment 
     $mail->AddAttachment('images/phpmailer_mini.gif'); // attachment 
     $mail->Send(); 
     echo "Message Sent OK</p>\n"; 
    } catch (phpmailerException $e) { 
     echo $e->errorMessage(); //Pretty error messages from PHPMailer 
    } catch (Exception $e) { 
     echo $e->getMessage(); //Boring error messages from anything else! 
    } 
    ?> 
+0

당신은 상단에 mail.yourdomain.com에 HOST를 설정하는 것 같다. 그것을 제거하고 도움이되는지보십시오. –

+0

아무런 차이가 없습니다. – San

답변

8

. 이 시스템의 설정이 이미 켜져있는 경우 내 머리 위로 떨어져 내가 php.ini 파일에서 = 당신이

확장 주석을 제거 할 필요가 PHP_openssl.dll

을 믿고 따라

는 SSL을 설치하는 데 도움이해야 :

http://us2.php.net/manual/en/openssl.installation.php

+0

wow..uncommenting extension = PHP_openssl.dll가 작동했습니다. 나는 그것이 왜 논평되었는지 이해하지 못한다. 이것은 PHP 코딩의 첫 날입니다. 배울게 많습니다. – San

+2

기본적으로 특정 기능이 주석 처리됩니다. php.ini를 살펴보면 몇 가지를 찾을 수 있습니다. 이것에 대한 이유는 확실하지 않습니다. 나는 당신이 일하는 것을 기쁘게 생각합니다. –

+0

+1 좋은 전화 Waleed. –

0

음, 필수 항목을 수정, 오류 메시지가 모든 말한다 :

Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?

그것은 것을 의미한다 PHP 버전은 SSL을 통해 메일 서버 (또는 그와 관련한 다른 서버)와 통신하는 데 필요한 라이브러리를 갖추고 있지 않습니다.

서버에 대한 루트 액세스 권한이없는 경우 이는 서버 관리자/제공자에게 문제 일 수 있습니다. similar discussion in a forum에서

, 매우 사실적인 소리 가능한 솔루션 : 그것은 그 SSL은 PHP에서 사용할 수 없습니다 보인다 오류를 바탕으로

My guess is that either mod_ssl is not installed for apache or it is installed but the configuration lines for mod_ssl are commented out in httpd.conf (like it was on suse9 for me). apxs will only enable ssl functions in php if mod_ssl is up and running

So check mod_ssl is available + enabled in apache then try recompiling php with

./configure --with-apxs2=/usr/sbin/apxs --with-mysql --enable-ssl

+0

"LoadModule ssl_module modules/mod_ssl.so"의 주석 처리를 제거하고 다시 시작했지만 변경 사항은 없지만 여전히 오류가 발생합니다. mod_ssl을 사용할 수 있는지 어떻게 확인할 수 있습니까 ?? – San

+0

PHP를'--enable-ssl'로 다시 컴파일해야한다고 생각합니다. 먼저'phoinfo();'에서 PHP 컴파일 방법을 확인하십시오. –

+0

@San : PHP에서도 지원이 필요합니다. Waleed가 상급으로 언급 한 것 같습니다. 참고 그는 연장에 관해서는 윈도우에게 특별한 지시를 주었다. * nix 박스에'.so'가 있어야한다. – prodigitalson

관련 문제