marol
marol

Reputation: 31

Code Igniter not sending email using SMTP

I'm already set the config like this

$config = Array(
        'protocol' => 'smtp', 
        'smtp_host' => 'ssl://smtp.gmail.com', 
        'smtp_port' => '465',
        'smtp_user' => '*****@gmail.com',
        'smtp_pass' => '****'
        );

but I can't send that email... It show error like this...

A PHP Error was encountered

Severity: Warning

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

Filename: libraries/Email.php

Line Number: 1673
A PHP Error was encountered

Severity: Warning

Message: fwrite(): supplied argument is not a valid stream resource

Filename: libraries/Email.php

Line Number: 1816

And many other errors...

Upvotes: 0

Views: 1613

Answers (1)

Deniz Cakiroglu
Deniz Cakiroglu

Reputation: 101

First try this code:

$config = Array(
    'protocol' => 'smtp',
    'smtp_host' => 'ssl://smtp.googlemail.com',
    'smtp_port' => 465,
    'smtp_user' => '*****@gmail.com',
    'smtp_pass' => '****'
    'mailtype'  => 'html', 
    'charset'   => 'utf-8'
);
$this->load->library('email', $config);

// Other stuff about to,from,subject...

$result = $this->email->send();

If it's not working, check your php.ini file. Change this line

;extension=php_openssl.dll

to

extension=php_openssl.dll

Upvotes: 1

Related Questions