Email setup in Code Igniter 2.02

I get a lot of errors. And I tried several suggestions on different sites, deleted the parent function, deleted the array, updated the php ini file, no luck. This is the first of 13 errors I get.

A PHP error has occurred Severity level: warning Message: fsockopen () [function.fsockopen]: could not connect to ssl: //smtp.googlemail.com: 465 (Could not find socket transfer "ssl" - you forgot to enable it when setting up PHP ?) File name: libraries / Email.php Line number: 1673

Someone please help.

class Email extends CI_Controller { function index() { $config['protocol'] = 'smtp'; $config['smtp_host'] = 'ssl://smtp.googlemail.com'; $config['smtp_port'] = 465; $config['smtp_user'] = ' myemail@gmail.com '; $config['smtp_pass'] = 'mypassword'; $this->load->library('email'); $this->email->initialize($config); $this->email->set_newline("\r\n"); $this->email->from(' myemail@gmail.com ', 'My Name'); $this->email->to(' myemail@gmail.com '); $this->email->subject('This is an email test'); $this->email->message('Its working. Great!'); if($this->email->send()) { echo 'Your email was sent, dude.'; } else { show_error($this->email->print_debugger()); } } 

}

+6
source share
2 answers

Use phpinfo (); in the .php file to check if the openssl extension is really loaded.

In php.ini enable php_openssl

 extension=php_openssl.so 

if you are on windows then

 extension=php_openssl.dll 
+10
source

Mayowa:

Maybe I was a little late, and you already decided that.

After much searching on the Internet, I found that simple quotes and double quotes do not match for mail configuration.

I use the file /application/config/email.php, and after many attempts it turned out that this will not work:

 $config['protocol'] = 'smtp'; $config['smtp_host'] = 'ssl://smtp.googlemail.com'; $config['smtp_port'] = 465; $config['smtp_user'] = ' myemail@gmail.com '; $config['smtp_pass'] = 'mypassword'; 

But it will be:

 $config['protocol'] = "smtp"; $config['smtp_host'] = "ssl://smtp.googlemail.com"; $config['smtp_port'] = 465; $config['smtp_user'] = " myemail@gmail.com "; $config['smtp_pass'] = "mypassword"; 

Hope this helps.

0
source

Source: https://habr.com/ru/post/891409/


All Articles