PHPMailer Warning: Peer Certificate Mismatch
PHPMailer users encountering the "PHP Warning: stream_socket_enable_crypto(): Peer certificate did not match expected" error under PHP 5.6 may be facing issues with certificate validation.
Background:
PHP 5.6 introduced stricter certificate verification for SSL connections. As a result, if the remote server's SSL configuration is incorrect, PHPMailer will fail to encrypt the connection.
Symptoms:
Solution:
The recommended solution is to correct the certificate or verification settings on the remote server. This may involve replacing an invalid certificate with a valid one or reconfiguring the SSL settings.
Alternative:
If immediate delivery is necessary and the certificate mismatch is not critical, you can disable certificate validation in PHPMailer using the following options:
$mail->SMTPOptions = array ( 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true));
Note: Disabling certificate validation is not recommended as it compromises security by potentially accepting invalid certificates.
The above is the detailed content of Why Does PHPMailer Throw a \'Peer Certificate Mismatch\' Error Under PHP 5.6?. For more information, please follow other related articles on the PHP Chinese website!