2
votes

I use CodeIgniter email library to make the forgot password function. When I tried it on localhost all goes well no error. But when I moved to the hosting server error occurs like this:

Severity: Warning

Message: fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Connection timed out)

Filename: libraries/Email.php

Line Number: 1986

This my code:

$ci = get_instance();
        $ci->load->library('email');
        $config['protocol'] = "smtp";
        $config['smtp_host'] = "ssl://smtp.gmail.com";
        $config['smtp_port'] = "465";
        $config['smtp_user'] = "[email protected]";
        $config['smtp_pass'] = "xxxxxxx";
        $config['charset'] = "utf-8";
        $config['mailtype'] = "html";
        $config['newline'] = "\r\n";

        $ci->email->initialize($config);

What should I do to fix this error?

1

1 Answers

0
votes

You need to enable SSL. Load php.ini and find a line with the following:

;extension=php_openssl.dll

Uncomment by removing the semicolon:

extension=php_openssl.dll

That has worked for me