我正在使用带有 wamp 的 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?)
文件名:库/Email.php
行号:1869
遇到以下 SMTP 错误:1706213911 无法找到套接字传输“ssl” - 您在配置 PHP 时是否忘记启用它?