php - Codeigniter 电子邮件在服务器 fsockopen() 中不起作用:无法连接到 ssl://smtp.googlemail.com:465(连接被拒绝)
问题描述
请在codeigniter电子邮件中帮助我,我尝试了很多次但没有成功,它在本地主机上工作但在服务器上没有工作。
错误:
遇到 PHP 错误
严重性:警告
消息:fsockopen():无法连接到 ssl://smtp.googlemail.com:465(连接被拒绝)
文件名:库/Email.php
行号:2069
回溯:
文件:/home/b4ger7ik8el2/public_html/account/application/controllers/Welcome.php 行:105 功能:发送
文件:/home/b4ger7ik8el2/public_html/account/index.php 行:315 功能:require_once
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'Email', // change it to yours
'smtp_pass' => 'Pasword', // change it to yours
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$message = "
<html>
<head>
<title>Verification Code</title>
</head>
<body>
<h2>Thank you for Registering.</h2>
<p>Dear:".$this->input->POST('firstname')."</p>
<p>Email: ".$this->input->POST('user_email')."</p>
<p>Please click the link below to activate your account.</p>
<h4><a href='".base_url()."welcome/activate/".$email=$this->input->POST('user_email')."/'>Activate My Account</a></h4>
</body>
</html>
";
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from($config['smtp_user']);
$this->email->to($this->input->POST('user_email'));
$this->email->subject('Signup Verification Email');
$this->email->message($message);
//sending email
if($this->email->send()){
$this->session->set_flashdata('Success','Your Account Has Been Created Please Check your email and verify your account..!');
}
else{
$this->session->set_flashdata('message', $this->email->print_debugger());
}
解决方案
您只需要从配置数组中的 SMTP 字符串中删除 SSL 部分,
config = array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'Email', // change it to yours
'smtp_pass' => 'Pasword', // change it to yours
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
推荐阅读
- javascript - 如何修复 TinyMCE 4 编辑器中出现的插件错误
- sql - Scala:使用 monotonically_increasing_id() 时在数据帧中排序
- java - 带有 RemoteWebDriver 的 WebStorage
- rust - 如何从另一个具有固定自我的方法调用需要固定自我的方法?
- python - 使用 pip 安装 Django 但在 pip 列表中看不到
- java - 对许多可选参数进行 Spring 数据 JPA 查询的最佳实践是什么?
- c# - 从使用 DMZ API 的公共 Web API 获取文件
- c++ - 如何区分函数模板特化中的数组和指针
- android - 在应用关闭的情况下使用“react-native-camera”
- ionic-framework - 使用 cmd 使用选项卡启动新的离子应用程序不起作用