0

I am working on php framework codeigniter,the email is not sending on localhost I have also removed the port 465 from the anti virus which I am using to send mail and also turned off the anti virus It gives the error " fsockopen(): SSL operation failed with code 1", fsockopen(): Failed to enable crypto

$config['protocol']  = 'smtp';
  $config['smtp_host'] = 'ssl://smtp.googlemail.com';
  $config['smtp_port'] = 465;
  $config['smtp_user'] = '*******@gmail.com'; // change it to yours
  $config['smtp_pass'] = '******'; // change it to yours
  $config['charset'  ] = 'iso-8859-1';
  $config['newline'  ] = "\r\n";

  $config['mailtype' ] = 'text';

  $config['validation' ] = TRUE;
   $this->load->library('email',$config);



    $this->email->from('*********@gmail.com');
    $this->email->to('********@gmail.com');   
    $this->email->subject('Confirmation Email');                                       
    $this->email->message('Thank you');                    

    if ($this->email->send()) 
    {
      echo "send successfully";


    }
    else
    {
      show_error($this->email->print_debugger());
    }

This is the code that I have done, can you please resolve this?

1 Answers1

0

Try this

use ssl://smtp.gmail.com.

$config = Array(
            'protocol' => 'smtp',
            'smtp_host' => 'ssl://smtp.gmail.com',
            'smtp_port' => 465,
            'smtp_user' => '*************@gmail.com', // change it to yours
            'smtp_pass' => '******', // change it to yours
            'mailtype' => 'html',
            'charset' => 'iso-8859-1',
            'wordwrap' => TRUE
          );
               $this->load->library('email', $config);
               $this->email->set_newline("\r\n");  
               $this->email->from('***@gmail.com'); // change it to yours
               $this->email->to('***@gmail.com');// change it to yours
               $this->email->subject('Confirmation Email');
               $this->email->message('Thank you');
             if($this->email->send())
             {
              /* echo 'Email sent.';*/

            echo "send successfully";

             }
             else
             {
              show_error($this->email->print_debugger());
             }

still facing same issue then try this link GMail fsockopen(): SSL operation failed error with Codeigniter and XAMPP

Naren Verma
  • 2,205
  • 5
  • 38
  • 95