5

A PHP Error was encountered

Severity: Warning

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

Filename: libraries/Email.php

Line Number: 1978

Codeigniter does not send e-mail because of this error.

My e-mail code:

$config = Array(
        'protocol'  => 'smtp',
        'smtp_host' => 'smtp.gmail.com',
        'smtp_port' => 587,
        'smtp_crypto' => 'tls',
        'smtp_user' => 'asd@gmail.com',
        'smtp_pass' => 'asd',
        'mailtype'  => 'html',
        'charset'   => 'utf-8'
    );

    $this->load->library('email', $config);
    $this->email->set_newline("\r\n");

    $this->email->from('asd@gmail.com', 'asd');
    $this->email->to($asd);

    $this->email->subject($asd);
    $this->email->message($asd);

    $this->email->send();
V. Mark
  • 195
  • 2
  • 4
  • 14
  • Your port is set on TSL.. change it to 465 and remove the smtp_crypto line – Ilanus Jan 03 '16 at 13:14
  • It gave me fwrite(): send of 6 bytes failed with errno=10054 An existing connection was forcibly closed by the remote host. error. If I use ssl://smtp.gmail.com then it gave me fsockopen(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed error – V. Mark Jan 03 '16 at 13:22
  • @IlanHasanov - Gmail only accepts TLS; see [Google Is Now Always Using TLS/SSL for Gmail Connections](http://www.internetsociety.org/deploy360/blog/2014/03/google-now-always-using-tlsssl-for-gmail-connections/). Also see [What is the difference between ports 465 and 587?](http://stackoverflow.com/q/15796530/608639) – jww Jan 03 '16 at 15:31
  • Set your CACert file. See, for example, [curl_setopt cacert.pem for paypal](http://stackoverflow.com/q/15362350). Or better, set it to the one CA that's needed (rather than the collection in ***`cacert.pem`***). – jww Jan 03 '16 at 15:35
  • What CA do I need? Could you explain this please? – V. Mark Jan 03 '16 at 15:40
  • I am getting same errors for CI Email library. I did not changed code. It was working fine for last few month and it started showing these error for last 2 days. We did not made any changes to server as well. – Jayesh Dhudashia Nov 08 '17 at 13:04
  • I am getting same error any one have solution please post and or paste line please. – Codebrekers Jan 03 '18 at 10:58

1 Answers1

2

This might help someone in the future.

Even if every credential is right, some antivirus or firewall installed in the machine might prevent sending email thru SMTP. Temporarily disabling the antivirus or firewall to check is a good idea.

In my case, Avast antivirus caused this issue, and disabling this resolved my problem.

To disable Avast intercepting SMTP, unchecking Scan outbound emails (SMTP) checkbox will do the trick.

Disable Avast SMTP interception

Sarvap Praharanayuthan
  • 4,212
  • 7
  • 47
  • 72