我正在使用带有wamp作为localserver的codeIgniter,我编写了发送电子邮件代码
$config = array(
'protocol'=>'smtp',
'smtp_port'=>'465',
'smtp_host'=>'ssl://smtp.googlemail.com',
'smtp_user'=>'myemail@gmail.com',
'smtp_pass'=>'*********'
);
$this->load->library('email',$config);
$this->email->set_newline("\r\n");//set the new line rule
$this->email->from('myemail@gmail.com', 'Imran Tufail');
$this->email->to('myemail@gmail.com');
$this->email->subject('Email Test');
$this->email->message("The stuff works");
if($this->email->send())
{
echo "Mail sent ";
}
else{
echo $this->email->print_debugger();
}
}
此代码生成错误
A PHP Error was encountered
Severity: Warning
Message: fsockopen(): unable to connect to ssl://smtp.googlemail.com:465 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?)
文件名:libraries / Email.php
行号:1869
遇到以下SMTP错误:1706213911无法找到套接字传输“ssl” - 您是否忘记在配置PHP时启用它?
答案 0 :(得分:2)
我解决了我的问题。因为我们正在使用ssl smtp并且没有在wamp服务器中启用ssl扩展
所以转到任务栏中的wanpserver图标,
wampserver->php->phpextansions-> then check the php_openssl extansion