【发布时间】:2018-09-16 07:40:41
【问题描述】:
从 VPS 发送电子邮件失败。它可以在我的本地主机上正常工作,但不能在实时服务器中工作。我的代码如下。
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'my gmail email',
'smtp_pass' => 'email password',
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('from-email', 'name');
$this->email->to('to-email');
$this->email->subject('Hello Test');
$this->email->message('Hello Message');
if ($this->email->send()) {
echo 'send';
}else {
show_error($this->email->print_debugger());
}
它在 localhost 中运行良好。 在我的 VPS 服务器中,它显示错误。
A PHP Error was encountered
Severity: Warning
Message: fsockopen(): unable to connect to ssl://smtp.googlemail.com:465 (Permission denied)
Filename: libraries/Email.php
Line Number: 1990
Backtrace:
File: /var/www/html/company/application/controllers/Welcome.php
Line: 46
Function: send
File: /var/www/html/company/index.php
Line: 315
Function: require_once
我还将 smtp_port 从 465 更改为 587 和 25。它仍然是相同的错误。
我该如何解决这个问题?
谁能告诉我,如何检查服务器中的 465 端口是否打开? 我的 VPS 服务器操作系统是:centos
感谢您的宝贵时间。
【问题讨论】:
标签: php linux codeigniter email vps