Reputation: 631
Getting error while sending email in my codeigniter project from live ubuntu 16.04 server. (On localhost it works fine.)
My smtp configuration is:
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => '[email protected]', // change it to yours
'smtp_pass' => 'password', // change it to yours
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
It's work fine on my local server. but when I host it on live server I got the error. How do I solve this error? Please help.
A PHP Error was encountered Severity: Warning
Message: fsockopen(): SSL: Connection reset by peer
Filename: libraries/Email.php
Line Number: 1990
Backtrace:
File: /var/www/project/company/application/libraries/SendEmail.php Line: 26 Function: send
File: /var/www/project/company/application/controllers/Login.php Line: 207 Function: send
File: /var/www/project/company/index.php Line: 315 Function: require_once
A PHP Error was encountered Severity: Warning
Message: fsockopen(): Failed to enable crypto
Filename: libraries/Email.php
Line Number: 1990
Backtrace:
File: /var/www/project/company/application/libraries/SendEmail.php Line: 26 Function: send
File: /var/www/project/company/application/controllers/Login.php Line: 207 Function: send
File: /var/www/project/company/index.php Line: 315 Function: require_once
A PHP Error was encountered Severity: Warning
Message: fsockopen(): unable to connect to ssl://smtp.googlemail.com:465 (Unknown error)
Filename: libraries/Email.php
Line Number: 1990
Backtrace:
File: /var/www/project/company/application/libraries/SendEmail.php Line: 26 Function: send
File: /var/www/project/company/application/controllers/Login.php Line: 207 Function: send
File: /var/www/project/company/index.php Line: 315 Function: require_once
Thanks.
Upvotes: 2
Views: 1418
Reputation: 11
I have had this error yesterday. The Error caused by SSL which has a problem on the server. So, I changed the SSL method to TLS to avoid the problem SSL. Configure your config with these rules.
$config['protocol'] = "smtp";
$config['smtp_host'] = "smtp.gmail.com";
$config['smtp_port'] = "587";
$config['smtp_user'] = "*[email protected]*";
$config['smtp_pass'] = "*yourpassword*";
$config['smtp_timeout'] = "4";
$config['charset'] = "utf-8";
$config['newline'] = "\r\n";
$config['smtp_crypto'] = "tls"; // This is an important part of changing to TLS
$config['validate'] = TRUE;
It's Works for me, Email is sent via TLS protocol. Maybe this is not the best solution for security.
Upvotes: 1