2
votes

I had a working code which was sending emails through the email->send function on Codeigniter. Since yesterday, this code has just stopped working.

Following is the code that I am using

$config = Array(
        'protocol'  => 'smtp',
        'smtp_host' => 'smtp.gmail.com',
        'smtp_port' =>  465,
        'smtp_user' => '[email protected]',
        '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('[email protected]', 'Finstler Support');
    $this->email->to($email);
    $this->email->subject('Reset Password requested');
    $body = $this->load->view('email-template/forgotpassword',$data,TRUE);
    $this->email->message($body);
    if (!$this->email->send())
    {
        // show_error($this->email->print_debugger());
        return false;
    }
    else
    {
        return true;
    }

I am receiving the below error since yesterday

Severity: Warning Message: fsockopen(): SSL: Handshake timed out Filename: libraries/Email.php Line Number: 2055

Message: fsockopen(): Failed to enable crypto

Message: fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Unknown error)

I have the openssl enabled on my machine and it correctly shows as enabled. Any help is highly appreciated !

1

1 Answers

0
votes

Try using below config:

$config = Array(
    'protocol'  => 'smtp',
    'smtp_host' => 'smtp.gmail.com',
    'smtp_port' =>  587,
    'smtp_user' => '[email protected]',
    'smtp_pass' => 'xxxx',
    'mailtype'  => 'html',
    'charset'   => 'utf-8',
    'smtp_crypto' => "tls"
);