GMail fsockopen(): SSL operation failed error with Codeigniter and XAMPP
Solution 1
In my case, the Avast Antivirus was blocking the port. I was using the SMTP port 465 for sending an email from my CodeIgniter project. It showed an error:
fsockopen() failed to enable crypto
Simply disabling the Avast Antivirus solved the problem.
Alternative 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
Solution 2
Today is April the 5th 2021 I have the same problem
xampp in windows and apache/php not sending emails.
After some debug you end up discovering that remote port 465 and 587 are not reachable. Finally you discover that disabling Avast the problem is solved.
That is how I have landed on this question.
But unfortunately the accepted solution looks not good anymore with current Avast so...
Where are Avast Redirect Settings in 2021?
Unfortunately looks like current Avast doesn't have anymore the Redirect Settings
Given that the temporary solution is to disable Avast protection (this works, you'll be able to send emails with PHPMailer and others mail libraries then) and given that:
- temporarily disable Avast for 10 minutes/1 hour every time is an annoying and potentially "dangerous" solution
- permanently disable Avast or the antivirus nowadays is not a good idea
I preferred a permanent and "more secure" one, in fact, if the antivirus works .. I can't have malicious emails sending from my computer
This is the permanent solution I have applied
- Open Avast User Interface (right click on the Avast tray icon)
- goto "Menu" (top right hamburger menu)
- then goto Settings>Protection (middle icon on the left panel)
- in the second column that appears click on "Main Protections"
- now in the right panel, scroll down to "Configure protection settings"
- under "Configure protection settings" there are 4 tabs
- the 4th tab is "e-mail protection"
- uncheck the "scan outgoing messages (SMTP)"
that is
V. Mark
Updated on April 05, 2021Comments
-
V. Mark about 3 years
Error message 1: Message: fsockopen(): 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: 1962
Error message 2: Message: fsockopen(): Failed to enable crypto Error message 3: Message: fsockopen(): unable to connect to >ssl://smtp.gmail.com:465 (Unknown error)
php.ini: extension=php_openssl.dll
-> uncommented I have tried with:openssl.cafile= C:\xampp\perl\vendor\lib\Mozilla\CA\cacert.pem
I have tried with disabled firewall I have tried with another networkCodeigniter PHP Code:
$config = Array( 'protocol' => 'smtp', 'smtp_host' => 'ssl://smtp.gmail.com', 'smtp_port' => 465, 'smtp_user' => '[email protected]', 'smtp_pass' => 'asd', 'mailtype' => 'html', 'charset' => 'utf-8' ); $this->load->library('email', $config); $this->email->set_newline("\r\n"); $this->email->from('[email protected]', 'asd'); $this->email->to($recipient); $this->email->subject($a); $this->email->message($b); $this->email->send();
-
Abilash Arjunan over 6 yearsHi, I am facing the same issue, but In my case I am using a different antivirus and I think my antivirus does not make any problem as I tested sending email by disabling the antivirus. Does any one have a better solution which could help me?
-
SouravOrii over 6 years@AbilashArjunan Do you have any security components installed which blocks port 465's outward communications. Please let me know if you have any defender or any sort of security measures on your development machine.
-
Sarvap Praharanayuthan almost 4 yearsThe answer is useful in latest version of Avast too. Year: 2020.