[英]Message: fsockopen(): unable to connect to ssl://smtp.googlemail.com:465 (Permission denied)
Email Sending failed from VPS. 从VPS发送电子邮件失败。 It works fine from my localhost but not working in live server.
它可以从我的本地主机正常工作,但不能在实时服务器上工作。 my code is given below.
我的代码如下。
$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());
}
It works fine in localhost . 它在localhost中可以正常工作。 In my VPS server, it shows error.
在我的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
I also changed my smtp_port from 465 to 587 and 25 . 我也将smtp_port从465更改为587和25 。 It remains the same error.
它仍然是相同的错误。
How do I solve this? 我该如何解决?
Can anyone tell me, how do I check 465 port is open or not in the server? 谁能告诉我,如何检查服务器中的465端口是否打开? My VPS server os is: centos
我的VPS服务器操作系统是: centos
Thanks for your time. 谢谢你的时间。
I try this, it's work for me. 我尝试这个,对我来说很有效。 I hope it's work for you too
我希望它也对你有用
$config['protocol'] = 'smtp';
$config['smtp_crypto'] = 'tls';
$config['smtp_host'] = 'smtp.gmail.com';
$config['smtp_port'] = '587';
My suggestion is you check on the ports, make sure your server firewall is permitting smtp . 我的建议是检查端口,确保服务器防火墙允许smtp 。 You might have to check on
您可能需要检查
. 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.