在笨

2012-06-06 46 views
0
發送電子郵件

哎有人能幫助我走出這個問題,我收到以下錯誤 一個PHP錯誤遇到在笨

Severity: Warning 

Message: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.googlemail.com:587 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) 

Filename: libraries/Email.php 

Line Number: 1689 

A PHP Error was encountered 

Severity: Warning 

Message: fwrite() expects parameter 1 to be resource, boolean given 

Filename: libraries/Email.php 

Line Number: 1846 

而且我有下面的代碼在我的emailer類

Class MailSender extends CI_Model{ 

    function __construct(){ 
     parent::__construct(); 
    } 

    public function sendMail(){ 
     $config=array(
       'protocol'=>'smtp', 
       'smtp_host'=> 'ssl://smtp.googlemail.com', 
       'smtp_port' => 587, 
       'smtp_user' => '[email protected]', 
       'smtp_pass' => 'signature08' 
     ); 

     $this->load->library('email',$config); 
     $this->email->set_newline("\r\n"); 

     $this->email->from("[email protected]"); 
     $this->email->to("[email protected]"); 
     $this->email->subject("this is a sample mail"); 
     $this->email->message("this is a sample message please check this"); 

     if($this->email->send()){ 
      //$data['message']="Email sent successfully"; 
      return true; 

     }else{ 
      //$data['message']="Couldnt sent the email, please provide me valid email address"; 
      return false; 
     } 

    } 
} 

回答

0

你有openssl擴展實際加載? 在.php文件中使用phpinfo();查看openssl擴展是否被加載 或者你是否對php.ini做過任何修改,導致了這種情況?

+0

我有這個在我的配置 ** Apache的版本\t的Apache/2.2.21(Win32的)的mod_ssl/2.2.21的OpenSSL/1.0.0e PHP/5.3.8的mod_perl/2.0.4的Perl/v5.10.1 ** .............................. ** OPENSSL_CONF \t C:/ xampp/apache/bin/openssl.cnf ** .......................................... ..................... ** SERVER_SIGNATURE \t

Apache/2.2.21(Win32)mod_ssl/2.2.21 OpenSSL/1.0.0e PHP/5.3.8 mod_perl/2.0.4 Perl/v5.10.1服務器在localhost上端口1234
SERVER_SOFTWARE \t Apache/2.2.21(Win32)mod_ssl/2.2.21 OpenSSL/1.0.0e PHP/5.3.8 mod_perl/2.0.4 Perl/v5.10.1 ** –

+0

如果一切正常,您的phpinfo( );應該列出這些流套接字傳輸: '註冊流套接字傳輸tcp,udp,ssl,sslv3,sslv2,tls' 否則請參閱我的答案。 – N1ck