Tanbir Ahmed
Tanbir Ahmed

Reputation: 320

Can't send email

I tried to send mail using the email class of CodeIgniter, but it is showing some errors:

fsockopen() [function.fsockopen]: unable to connect to
ssl://smtp.googlemail.com:465 (Unable to find the socket transport
"ssl" - did you forget to enable it when you configured PHP?)

My code is here:

        $config['protocol'] = 'smtp';
        $config['smtp_host'] = 'ssl://smtp.googlemail.com';
        $config['smtp_port'] = 465;
        $config['smtp_user'] = '[email protected]';
        $config['smtp_pass'] = 'email';

        $this->load->library('email');
        $this->email->initialize($config);
        $this->email->set_newline("\r\n");        
       $message="
           username:{$this->input->post('username')}
           password:{$this->input->post('password')}
            ";
       $this->email->from('[email protected]','Admin');
       $this->email->to($this->input->post('email'));
       $this->email->subject('Activation Message');
       $this->email->message($message);
       $this->email->send();
       echo $this->email->print_debugger();

I also changed the php.ini file and pasted extension=php_openssl.dll in it, but it still does not work.

Upvotes: 0

Views: 115

Answers (1)

DaneoShiga
DaneoShiga

Reputation: 1027

The smtp server from gmail is smtp.gmail.com

so your configuration should be:

$config['protocol'] = 'smtp';  
$config['smtp_host'] = 'ssl://smtp.gmail.com';  
$config['smtp_port'] = 465;  
$config['smtp_user'] = '[email protected]';
$config['smtp_pass'] = 'email';

but I'm not sure if smtp_host need the 'ssl://' part

Upvotes: 1

Related Questions