codeigniter - fsockopen():无法连接到 ssl://smtp.gmail.com:465(权限被拒绝)
问题描述
遇到 PHP 错误 严重性:警告消息:fsockopen():无法连接到 ssl://smtp.gmail.com:465(权限被拒绝)
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'user',
'smtp_pass' => 'password',
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
解决方案
如果您正在运行 Red Hat 衍生产品,它们会默认启用 SELinux,并且可能会php-fpm
被拒绝访问创建套接字。尝试通过运行来检查它grep php /var/log/audit/audit.log | grep denied
。
如果是这样,您可以/usr/sbin/setsebool httpd_can_network_connect 1
以 root 身份运行,然后尝试再次运行代码。
推荐阅读
- neural-network - 在 loss.backward() 之后使用 zero_grad(),但仍然收到 RuntimeError:" Trying to back through the graph a second time..."
- c++ - 使用 QProcess 静默执行 CMD 命令
- html - 在不使用背景颜色的情况下向 HTML 表格单元格添加背景颜色?
- java - 不断获取 org.hibernate.AnnotationException: @OneToOne 或 @ManyToOne 引用未知实体:错误
- page-tables - sbrk 后访问非法地址
- java - Android防止双击布局与handher
- statistics - 如何比较不同样本量的不同组?
- ios - 把 UIView 放到前面
- javascript - 动态排序对象数组javascript
- python - UnboundLocalError:分配前引用的局部变量“qn”