解决PHPMailer Error SMTP Connect failed
Resolve PHPMailer Error SMTP Connect failed
如何解决 phpmailer 中的这个错误?几个月前我测试时从未发生过这种情况。
2019-06-18 15:26:33 Connection: opening to ssl://localhost:465, timeout=300, options=array ( )
2019-06-18 15:26:33 Connection: Failed to connect to server. Error number 2. "Error notice: stream_socket_client(): Peer certificate CN=`server18.hostingraja.org' did not match expected CN=`localhost'
2019-06-18 15:26:33 Connection: Failed to connect to server. Error number 2. "Error notice: stream_socket_client(): Failed to enable crypto
2019-06-18 15:26:33 Connection: Failed to connect to server. Error number 2. "Error notice: stream_socket_client(): unable to connect to ssl://localhost:465 (Unknown error)
2019-06-18 15:26:33 SMTP ERROR: Failed to connect to server: (0)
2019-06-18 15:26:33 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting`
错误消息告诉您问题所在
Peer certificate CN=server18.hostingraja.org' did not match expected CN=
localhost'
所以您的代码(您没有显示)可能在做类似的事情:
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->Host = 'localhost`;
这行不通,因为您无法获得 localhost
的可验证证书。解决此问题的两种方法:
$mail->SMTPSecure = false;
$mail->Port = 25;
这只是禁用加密,您不需要加密,因为您只是连接到本地主机。
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->Host = 'server18.hostingraja.org`;
这样您仍然连接到同一台服务器,但使用正确的名称以便可以验证证书。
如果您有任何其他问题,请阅读错误消息链接到的故障排除指南,并在您之前进行搜索post。
如何解决 phpmailer 中的这个错误?几个月前我测试时从未发生过这种情况。
2019-06-18 15:26:33 Connection: opening to ssl://localhost:465, timeout=300, options=array ( )
2019-06-18 15:26:33 Connection: Failed to connect to server. Error number 2. "Error notice: stream_socket_client(): Peer certificate CN=`server18.hostingraja.org' did not match expected CN=`localhost'
2019-06-18 15:26:33 Connection: Failed to connect to server. Error number 2. "Error notice: stream_socket_client(): Failed to enable crypto
2019-06-18 15:26:33 Connection: Failed to connect to server. Error number 2. "Error notice: stream_socket_client(): unable to connect to ssl://localhost:465 (Unknown error)
2019-06-18 15:26:33 SMTP ERROR: Failed to connect to server: (0)
2019-06-18 15:26:33 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting`
错误消息告诉您问题所在
Peer certificate CN=
server18.hostingraja.org' did not match expected CN=
localhost'
所以您的代码(您没有显示)可能在做类似的事情:
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->Host = 'localhost`;
这行不通,因为您无法获得 localhost
的可验证证书。解决此问题的两种方法:
$mail->SMTPSecure = false;
$mail->Port = 25;
这只是禁用加密,您不需要加密,因为您只是连接到本地主机。
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->Host = 'server18.hostingraja.org`;
这样您仍然连接到同一台服务器,但使用正确的名称以便可以验证证书。
如果您有任何其他问题,请阅读错误消息链接到的故障排除指南,并在您之前进行搜索post。