2012-07-18 15 views
2

我想在用戶註冊時向用戶發送確認電子郵件。我正在使用xampp。當我運行我的PHP文件,它返回以下錯誤:fsockopen()有關在php中發送郵件的錯誤

Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) in C:\xampp\htdocs\class.smtp.php on line 122 

    Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) in C:\xampp\htdocs\class.smtp.php on line 122 
    Message has not been sent. 

相關部分在我的PHP文件:

try 
    { 
     require("class.phpmailer.php"); 
     $mail = new PHPMailer(); 
     $mail->IsSMTP(); 
     $mail->Mailer = "smtp"; 
     $mail->SMTPSecure = "ssl"; 
     $mail->Host = "ssl://smtp.gmail.com"; 
     $mail->Port = 465; 
     $mail->SMTPAuth = true; 
     $mail->CharSet="utf-8"; 
     $mail->Username = "[email protected]"; 
     $mail->Password = "password"; 
     $mail->From  = "[email protected]"; 
     $mail->FromName="DBE Yazılım"; 
     $mail->AddAddress($_POST['UserMail']); 
     $mail->Subject = "Registration Information"; 
     $mail->Body  = "Hello your password is " . $userpass; 
     //$mail->AddAttachment($path); 
     $mail->Send(); 
     if($mail->Send()) 
      echo 'Message has been sent.'; 
     else 
      echo 'Message has not been sent.'; 
    } 
    catch(Exception $e) 
    { 
     echo 'hata'.$e->getMessage(); 
    } 

我已經看過論壇,這個錯誤通常是關於SSL。他們說extension=php_openssl.dll必須添加到php.ini中。我添加了這部分,但沒有任何改變。這是關於xampp的嗎?

在此先感謝。

回答

2

正如你可以在錯誤消息

unable to connect to ssl://ssl://smtp.gmail.com:465 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) in C:\xampp\htdocs\class.smtp.php on line 122

有一個ssl://太多

$mail->Host = "smtp.gmail.com"; // instead of ssl://smtp.gmail.com 

平時如果看到術語「宿主」看,這真的意味着「主機」,而不是一個網址

+0

我已更改爲「$ mail-> Host =」smtp.gmail.com「;」但錯誤不會改變。 – rockenpeace 2012-07-18 11:41:12