简体   繁体   中英

Codeigniter send email OpenSSL error

I am having trouble sending email. I don't know what to do. I already un-commented the extension=php_openssl.dll in php.ini file, but I still receive this error.

Here is my code:

function send_email(){
        $config = array(
            'protocol' => 'smtp',
            'smtp_host' => 'ssl://smtp.googlemail.com',
            'smtp_port' => '465',
            'smpt_timeout' => '30',
            'smtp_user' => 'example@gmail.com',
            'smtp_pass' => $pass,
            'charset' => 'utf-8',
            'newline' => "\r\n"
        );


        $this->load->helper('string');
        $this->load->library('email',$config);

        $this->email->from('example@yahoo.com', 'Mr. Duterte');
        $this->email->to('example2@yahoo.com');

        $this->email->subject('DU30');
        $this->email->message('change is coming');
        //.base_url().'item/'.random_string

       if( $this->email->send()){
           echo "Success";
       }else{
           echo "Fail";

       }
    }

And I am getting three errors:

First:

"fsockopen(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed"

Second:

fsockopen(): Failed to enable crypto

Third:

fsockopen(): unable to connect to ssl://smtp.googlemail.com:465 (Unknown error)

I have figured out the problem. I just turned off my antivirus (Avast).

Avast Antivirus was blocking the port. I was using the SMTP port 465 for sending an email from CodeIgniter project:

fsockopen() failed to enable crypto

Simply disabling the Avast Antivirus solved the problem .

Another Solution but if you want to keep your Avast security on, you should:

  • Open Avast

  • Click on Settings (upper right corner of page)

  • Click on Troubleshooting

  • Click on Redirect Settings

  • Clear the port you used from Redirect Settings's MAIL section

  • Click OK

  • Close Avast

I'm getting the same issue on the nginx server. Upgraded OpenSSL to 1.1.1 but still the same. On my laptop, I'm using Kaspersky but in my case antivirus is not making any issues on the server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM