GMail fsockopen(): SSL operation failed error with Codeigniter and XAMPP GMail fsockopen(): SSL operation failed error with Codeigniter and XAMPP codeigniter codeigniter

GMail fsockopen(): SSL operation failed error with Codeigniter and XAMPP


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


Today is April the 5th 2021I 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

  1. Open Avast User Interface (right click on the Avast tray icon)
  2. goto "Menu" (top right hamburger menu)
  3. then goto Settings>Protection (middle icon on the left panel)
  4. in the second column that appears click on "Main Protections"
  5. now in the right panel, scroll down to "Configure protection settings"
  6. under "Configure protection settings" there are 4 tabs
  7. the 4th tab is "e-mail protection"
  8. uncheck the "scan outgoing messages (SMTP)"

that is