2013-06-15 3 views
0

phpmailer 클래스를 사용하고있는 웹 메일에서 작업 중입니다. "SMTP 오류 : SMTP 호스트에 연결할 수 없습니다. 메시지가 전송되지 않았습니다. PHP 메일러 오류 : SMTP 오류 : SMTP 호스트에 연결할 수 없습니다. ""SMTP 오류 SMTP 호스트에 연결할 수 없습니다. 메시지가 전송되지 않았습니다.

내 코드는 다음과 같습니다

<html> 
<head> 
<title>PHPMailer - SMTP basic test with authentication</title> 
</head> 
<body> 

<?php 

//error_reporting(E_ALL); 
error_reporting(E_STRICT); 

date_default_timezone_set('America/Toronto'); 

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

$mail    = new PHPMailer(); 

$body    = file_get_contents('contents.html'); 
$body    = eregi_replace("[\]",'',$body); 

$mail->IsSMTP(); 
$mail->Port = 465; 
$mail->Host = 'smtp.gmail.com'; // "ssl://smtp.gmail.com" didn't worked 
$mail->IsHTML(true); // if you are going to send HTML formatted emails 
$mail->Mailer = 'smtp'; 
$mail->SMTPSecure = 'ssl'; 

$mail->SMTPAuth = true; 
$mail->Username = "[email protected]"; 
$mail->Password = "mypass"; 

$mail->SingleTo = true; // if you want to send mail to the users individually so that no recipients can see that who has got the same email. 

$mail->From = "[email protected]"; 
$mail->FromName = "mypass"; 

$mail->addAddress("[email protected]","User 1"); 
$mail->addAddress("[email protected]","User 2"); 

$mail->addCC("[email protected]","User 3"); 
$mail->addBCC("[email protected]","User 4"); 

$mail->Subject = "Testing PHP Mailer with localhost"; 
$mail->Body = "Hi,<br /><br />This system is working perfectly."; 

if(!$mail->Send()) 
    echo "Message was not sent <br />PHP Mailer Error: " . $mail->ErrorInfo; 
else 
    echo "Message has been sent"; 

?> 

</body> 
</html> 

And my php.ini setting is : 

    [mail function] 
; For Win32 only. 
; http://php.net/smtp 
;SMTP = 
; http://php.net/smtp-port 
;smtp_port = 465 

; For Win32 only. 
; http://php.net/sendmail-from 
;sendmail_from = [email protected] 
; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). 
; http://php.net/sendmail-path 
sendmail_path ="C:\wamp\sendmail\sendmail.exe -t -i" 

; Force the addition of the specified parameters to be passed as extra parameters 
; to the sendmail binary. These parameters will always replace the value of 
; the 5th parameter to mail(), even in safe mode. 
; 

누군가가 나에게 내가 잘못 경우, 나는이 문제에 당신의 친절한 관심을 필요 알려 드리고자합니다.

답변

2

사용자의 SMTP 호스트가 올바르게 설정되어 있지만 다음 $ 메일 -> 메일러 = 'SMTP'한

$mail->SMTPSecure = 'tls'; 
+0

나는 그것을 대체했습니다. 브라우징에 시간이 걸립니다. 페이지가 비어 있습니다. 코드가 성공적으로 실행되었음을 의미합니까? 그 외의 경우 "메시지를 보냈습니다"; 메시지를 표시합니까 –

+0

예, 이는 코드로서 올바른 것을 의미합니다. –

0

으로

$mail->SMTPSecure = 'ssl'; 

교체하십시오; 은 $ mail-> Mailer = 'mail'이어야합니다. 직접 smtp를 보내려면 자신의 smtp 서버가 없다면 ... .. 나는 꽤 잘 모르겠지만, 젠체하는 사람을 경험했습니다 ...;)

관련 문제