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

This is not a codeigniter problem, but a php settings related problem. The answer to this question can be found here: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?

One thing to note is that in codeigniter you can use an e-mail config file, to hold all your config settings. (so you don't have to define them each time in a controller). You can do this by creating the file: application/config/email.php you can then fill this file with your settings, like this:

<?php defined('BASEPATH') OR exit('No direct script access allowed');

$config = array(
    'protocol' => 'smtp', // 'mail', 'sendmail', or 'smtp'
    'smtp_host' => 'your_host',
    'smtp_port' => your_port,
    'smtp_user' => 'your_email',
    'smtp_pass' => 'your_password',
    'smtp_crypto' => 'security', //can be 'ssl' or 'tls' for example
    'mailtype' => 'html', //plaintext 'text' mails or 'html'
    'smtp_timeout' => '4', //in seconds
    'charset' => 'iso-8859-1',
    'wordwrap' => TRUE
);

each time you load the library ($this->load->library('email');) these settings will be automatically loaded.

Also I recommend that you change your e-mail password immediately because you wrote your credentials in your question.


I am facing the same problem with Email on a server, the solution for this problem is to change the 'protocol' from 'smtp' to 'ssmtp' and 'smtp_host' from 'ssl://smtp.gmail.com' to 'ssl://ssmtp.googlemail.com'. This thing is working fine for me.

Tags:

Codeigniter