Guides & TutorialsTroubleshootingEmail TroubleshootingSMTP connect() failed Error with External SMTP Mail Providers

SMTP connect() failed Error with External SMTP Mail Providers

Symptom

When sending emails using an external SMTP mail provider (including Gmail™), a SMTP connect() failed error displays in WHMCS and appears in the Configuration > System Log:

SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Validation Error: SMTP connect() failed.

If you have enabled SMTP Debug for your mail provider in the Mail tab at Configuration > System Settings > General Settings, the log entry will also include the following details:

SMTP Debug: Connection: opening to ssl://smtp.gmail.com:465, timeout=300, options=array()

SMTP Debug: Connection failed. Error #2: stream_socket_client(): SSL  operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate  verify failed  [/path/to/whmcs/vendor/phpmailer/phpmailer/src/SMTP.php  line 375]

SMTP Debug: Connection failed. Error #2:  stream_socket_client(): Failed to enable crypto  [/path/to/whmcs/vendor/phpmailer/phpmailer/src/SMTP.php  line 375]

SMTP Debug: Connection failed. Error #2:  stream_socket_client(): unable to connect to ssl://smtp.gmail.com:465  (Unknown error)  [/path/to/whmcs/vendor/phpmailer/phpmailer/src/SMTP.php  line 375]

SMTP Debug: SMTP ERROR: Failed to connect to server:  (0)

SMTP Debug: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

For more information about enabling SMTP Debug, see Email Sending Issues.

Cause

The server that hosts your WHMCS installation is blocking connections to the external SMTP server.

Solution

Adjust your mail server configuration to allow connections to external SMTP servers.

For steps to resolve this issue on the cPanel and Plesk control panels, see:

For help making this change, contact your hosting provider or system administrator.