0

I am using wamp server with the latest version of CodeIgniter. I have uncomment the line that says extension=php_openssl.dllfrom my php.ini. I don't have AVG anti-virus installed. Yet it's not working. I have the email library autoloaded in my autoload.php

My mail sender controller:

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

class Testmail extends CI_Controller {

public function index()
{ 
    //configure email settings
    $config['protocol'] = 'sendmail';
    $config['smtp_host'] = 'ssl://smtp.gmail.com'; //smtp host name
    $config['smtp_port'] = '465'; //smtp port number
    $config['smtp_user'] = 'my_email@gmail.com';
    $config['smtp_pass'] = 'correct_password'; //$from_email password
    $config['mailtype'] = 'html';
    $config['charset'] = 'iso-8859-1';
    $config['wordwrap'] = TRUE;
    $config['newline'] = "\r\n"; //use double quotes
    $this->email->initialize($config);

    //send mail
    $this->email->from('nosisky@gmail.com', 'Mydomain');
    $this->email->to('nosisky@gmail.com');
    $this->email->subject('testing mail');
    $this->email->message('testing mail server class');
    $this->email->send();
    echo $this->email->print_debugger(); 
}


}

This is a part of the error message I got when I printed the CodeIgniter email debugger.

A PHP Error was encountered

Severity: Warning

Message: fsockopen(): SSL operation failed with code 1. OpenSSL Error 
messages: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown 
protocol

Filename: libraries/Email.php

Line Number: 2063
dealwap
  • 621
  • 2
  • 14
  • 33
  • Possible duplicate of [GMail fsockopen(): SSL operation failed error with Codeigniter and XAMPP](https://stackoverflow.com/questions/34570064/gmail-fsockopen-ssl-operation-failed-error-with-codeigniter-and-xampp) – Joe Jun 15 '17 at 16:45
  • I've followed the steps outlined but its not working. – dealwap Jun 15 '17 at 16:47

1 Answers1

0

i used below code. it's worked fine. Change protocol to smtp. Also try removing or containing ssl:// in your code.

$config = array(
        'protocol' => 'smtp',
        'smtp_host' => 'ssl://just127.justhost.com',
        'smtp_port' => 465,
        'smtp_user' => 'user@gmail.com',
        'smtp_pass' => 'yourpassword',
        'mailtype' => 'html',
        'charset' => 'iso-8859-1'
);
kazinayem2011
  • 348
  • 6
  • 20