Files
PHPSemapForm/OPENSSL_SETUP.md
2025-12-09 10:07:14 +01:00

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

  1. Find your php.ini file:

    php --ini
    

    If 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
    
  2. Edit php.ini and find this line:

    ;extension=openssl
    

    Remove the semicolon to uncomment it:

    extension=openssl
    
  3. Restart your PHP server (or command line if using built-in server)

  4. 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 successfully
  • Email sent successfully via SMTP

Alternative: Use a Different SMTP Port

If you absolutely cannot enable OpenSSL, you could try:

  1. Contact your email administrator to see if there's an unencrypted SMTP port (not recommended for security)
  2. 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