1. First step
Open the debugging mode to view the error message
$mail->SMTPDebug = 2;
2. Add the following code to skip validation
Generally, for example, QQ mailbox and 163 mailbox will not fail to connect to the SMTP server. For example, the mail server with its own company domain name is prone to sending failure.
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
The referendum decided:
Link: https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
stack overflow: https://stackoverflow.com/questions/3477766/phpmailer-smtp-error-could-not-connect-to-smtp-host
Read More:
- [Solved] PHPMailer Error: SMTP ERROR: Failed to connect to server: (0)
- php Error: mail() Failed to connect to mailserver at “localhost” port 25
- [PHP] php8 jit does not support 32-bit systems WARNING: JIT not supported by host architecture
- [Solved] WordPress Upgrade PHP 5.6 to 7.x Fatal error: Uncaught Error: Call to undefined function mysql_connect()
- [Solved] PHP Error: Warning: file_get_contents(): Failed to enable crypto
- [PHP] Solve PHP Call to undefined function ldap_connect()
- composer Failed to decode response: zlib_decode(): data error
- PHP Error Object of class mysqli could not be converted to string in
- [Solved] Laravel Upload Files Verificate Error: The file failed to upload.
- Using $this when not in object context in (How to Fix)
- php_network_getaddresses: getaddrinfo failed (How to Fix)
- [Solved] file_get_contents(): SSL operation failed with code 1
- [Solved] ‘node’ command failed to start the project, with an error: “unknown database’ mydb ‘”
- [Solved] Warning: Unknown: Failed to write session data using user defined save handler. (session.save_path:
- How to Solve PHP Fatal error: Namespace declaration statement has to be the very first statement
- How to Solve opcache error: zend_mm_heap corrupted
- [Solved] Fatal error: Class ‘think\Container‘ not found & [InvalidArgumentException] Could not find package
- [PHP] Array to string conversion error when sending data in post
- How to solve Magento 500 internal server errors
- [Solved] PHP getimagesize(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL