2.4 KiB
Enabling OpenSSL Extension in PHP (Windows)
Problem
Your PHP installation doesn't have the OpenSSL extension enabled, which is required for secure SMTP connections (TLS/SSL).
Current error: Unable to find the socket transport "ssl" or TLS/SSL transports not available
Solution
Option 1: Enable OpenSSL in php.ini (Recommended)
-
Find your php.ini file:
php --iniIf it shows "Loaded Configuration File: (none)", you need to create one:
# Find PHP installation directory where.exe php # Copy the example php.ini cd C:\path\to\php copy php.ini-development php.ini -
Edit php.ini and find this line:
;extension=opensslRemove the semicolon to uncomment it:
extension=openssl -
Restart your PHP server (or command line if using built-in server)
-
Verify OpenSSL is enabled:
php -m | Select-String -Pattern "openssl"Should output:
openssl
Option 2: Enable OpenSSL temporarily via command line
You can enable OpenSSL for a single command:
php -d extension=openssl test_email.php
Or for the built-in server:
php -d extension=openssl -S localhost:8000
Option 3: Install Composer and PHPMailer
If you can't modify php.ini, install PHPMailer which may handle SMTP better:
# Install Composer first (https://getcomposer.org/)
# Then in the php/ directory:
composer require phpmailer/phpmailer
The application will automatically detect and use PHPMailer if available.
Verifying the Fix
After enabling OpenSSL, run the test:
cd C:\Users\aky547\GitHub\SemapForm\php
php test_email.php
You should see:
Available transports: tcp, udp, ssl, tls(or similar)TLS encryption enabled successfullyEmail sent successfully via SMTP
Alternative: Use a Different SMTP Port
If you absolutely cannot enable OpenSSL, you could try:
- Contact your email administrator to see if there's an unencrypted SMTP port (not recommended for security)
- Use a different email solution (e.g., send via a web service API instead of SMTP)
Production Deployment
On a production server (Linux/shared hosting):
- OpenSSL is usually enabled by default
- Check with
php -m | grep openssl - If not available, contact your hosting provider
- Most shared hosting environments have it pre-configured