php – 发送邮件的SMTP协议不能与codeigniter一起使用
发布时间:2020-12-13 22:27:37 所属栏目:PHP教程 来源:网络整理
导读:$config = Array('protocol' = 'smtp','smtp_host' = 'smtp.gmail.com','smtp_port' = 465,'smtp_user' = 'XXXX@XXXX.com','smtp_pass' = 'XXXX','mailtype' = 'html','charset' = 'iso-8859-1');$this-load-library('email',$config);$this-email-set_newli
$config = Array( 'protocol' => 'smtp','smtp_host' => 'smtp.gmail.com','smtp_port' => 465,'smtp_user' => 'XXXX@XXXX.com','smtp_pass' => 'XXXX','mailtype' => 'html','charset' => 'iso-8859-1' ); $this->load->library('email',$config); $this->email->set_newline("rn"); $this->email->from('xxxxx@xxx.com','xxxx'); $this->email->to($email); $this->email->subject('Hi'); $this->email->message('Hi'); if($this->email->send()) { echo 'Your email was sent.'; } else { show_error($this->email->print_debugger()); } 但它显示错误消息:fsockopen():无法连接到smtp.gmail.com:465(连接被拒绝). 我在这里看到了解决方案Sending mail with CodeIgniter using SMTP protocol not working,但它无法正常工作,我无法找到php.ini. 解决方法
我正在使用这种方式,它对我有用:
$config = array( 'protocol' => 'smtps','smtp_host' => 'ssl://smtps.googlemail.com','smtp_user' => DONOT_EMAIL,'smtp_pass' => EMAIL_PASSWORD,'smtp_port' => '465','mailtype' => 'html','smtp_timeout' => '4','newline' => "rn" ); 这段代码我用于服务器端. $this->email->initialize($config); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |