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
我的电子邮件类
中有以下代码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' => 'bhatta.bj@gmail.com',
'smtp_pass' => 'signature08'
);
$this->load->library('email',$config);
$this->email->set_newline("\r\n");
$this->email->from("bhatta.bj@gmail.com");
$this->email->to("curtains_v@hotmail.com");
$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 :(得分:1)
代码工作正常,请确保您已加载openssl扩展。
http://www.devcha.com/2010/01/php-fsockopen-unable-to-connect-ssl.html
答案 1 :(得分:0)
你有实际加载的openssl扩展吗? 在.php文件中使用phpinfo();来查看是否加载了openssl扩展 或者您是否对php.ini进行了任何修改?