I have searched this problem a lot for the past many hours and still stuck with the issue. None of the solutions have worked for me. The feature I have coded is to send mail on user registration. It was working fine till yesterday and today I am seeing a lot of issues. The problem is sometimes the mail is delivered while sometimes it randomly throws up an error.
I get the following error when I try to send an email -
Severity: Warning
Message: fsockopen(): SSL: Handshake timed out
Filename: libraries/Email.php
Line Number: 2055
Backtrace:
A PHP Error was encounteredSeverity: Warning
Message: fsockopen(): Failed to enable crypto
Filename: libraries/Email.php
Line Number: 2055
Severity: Warning
Message: fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Unknown error)
Filename: libraries/Email.php
Line Number: 2055
The really annoying thing is that it comes erratically. Works sometimes and them just stops.
Following is the piece of code I use to send email - (This was working fine till yesterday)
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.gmail.com',
'smtp_port' => 465,
'smtp_user' => 'xxxx@gmail.com',
'smtp_pass' => 'xxxx',
'mailtype' => 'html',
'charset' => 'utf-8',
'smtp_crypto' => "ssl"
);
$data = array(
'userName'=> $firstName,
'link'=>$url
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->set_mailtype("html");
$this->email->from('finstlerforum@gmail.com', 'Finstler Support');
$this->email->to($email);
$this->email->subject('Please verify your email address');
$body = $this->load->view('email-template/verifyemail',$data,TRUE);
$this->email->message($body);
if (!$this->email->send())
{
// show_error($this->email->print_debugger());
return false;
}
else
{
return true;
}