我无法发送电子邮件。我不知道该怎么做。我已经在php.ini文件中取消了对 extension = php_openssl.dll 的评论,但我仍然收到此错误。
这是我的代码:
function send_email(){
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => '465',
'smpt_timeout' => '30',
'smtp_user' => 'example@gmail.com',
'smtp_pass' => $pass,
'charset' => 'utf-8',
'newline' => "\r\n"
);
$this->load->helper('string');
$this->load->library('email',$config);
$this->email->from('example@yahoo.com', 'Mr. Duterte');
$this->email->to('example2@yahoo.com');
$this->email->subject('DU30');
$this->email->message('change is coming');
//.base_url().'item/'.random_string
if( $this->email->send()){
echo "Success";
}else{
echo "Fail";
}
}
我得到三个错误:
首先:
" fsockopen():SSL操作失败,代码为1. OpenSSL错误 消息:错误:14090086:SSL 例程:ssl3_get_server_certificate:证书验证失败"
第二
fsockopen():无法启用加密
第三
fsockopen():无法连接到ssl://smtp.googlemail.com:465 (未知错误)
答案 0 :(得分:1)
我已经找到了问题所在。我刚刚关闭了我的防病毒软件(Avast)。
答案 1 :(得分:0)
Avast Antivirus阻止了该端口。我正在使用SMTP端口465从CodeIgniter项目发送电子邮件:
fsockopen()无法启用加密
只需禁用Avast防病毒软件 即可解决问题。
另一种解决方案,但是如果要保持Avast安全性,则应该:
打开 Avast
单击设置(在页面的右上角)
单击故障排除
点击重定向设置
清除重定向设置的邮件部分
点击确定
关闭Avast