phpmailer发送邮件出现错误:stream_socket_enable_crypto(): SSL operation failed with code 1.

简介: 如果开了调试,调试进去会看到错误提示: [cpp] view plain copy smtp_code:"stream_socket_enable_crypto(): SSL operation failed with code 1.

如果开了调试,调试进去会看到错误提示:

 

[cpp]  view plain  copy
 
  1. smtp_code:"stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:\nerror:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed"  

最终提示是:Could not connect to SMTP host

 

原因是升到php5.6后默认开启验证

添加参数,去掉验证:

 

[php]  view plain  copy
 
  1. $mail->SMTPOptions = array(  
  2.     'ssl' => array(  
  3.         'verify_peer' => false,  
  4.         'verify_peer_name' => false,  
  5.         'allow_self_signed' => true,  
  6.     )  
  7. )  

 

 

参考文档:

http://php.net/manual/en/context.ssl.php

去掉验证:

I am unable to load a PEM that was generated with the stunnel tools. However, I am able to use PHP calls to generate a working PEM that is recognized both by stunnel and php, as outlined here:

http://www.devdungeon.com/content/how-use-ssl-sockets-php

This code fragment is now working for me, and with stunnel verify=4, both sides confirm the fingerprint. Oddly, if "tls://" is set below, then TLSv1 is forced, but using "ssl://" allows TLSv1.2:

$stream_context = stream_context_create([ 'ssl' => [
'local_cert'        => '/path/to/key.pem',
'peer_fingerprint'  => openssl_x509_fingerprint(file_get_contents('/path/to/key.crt')),
'verify_peer'       => false,
'verify_peer_name'  => false,
'allow_self_signed' => true,
'verify_depth'      => 0 ]]);

$fp = stream_socket_client('ssl://ssl.server.com:12345',
   $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $stream_context);
fwrite($fp, "foo bar\n");
while($line = fgets($fp, 8192)) echo $line;

 

http://php.net/manual/en/context.ssl.php

如何联系我:【万里虎】www.bravetiger.cn 【QQ】3396726884 (咨询问题100元起,帮助解决问题500元起) 【博客】http://www.cnblogs.com/kenshinobiy/
目录
相关文章
|
6月前
|
前端开发 Java 网络安全
基于Java Socket实现的SMTP邮件客户端 - 全面支持SSL, TLS
基于Java Socket实现的SMTP邮件客户端 - 全面支持SSL, TLS
64 0
|
7月前
|
消息中间件 Kafka
org.apache.kafka.common.KafkaException: Socket server failed to bind to 114.115.20.100:9092: Cannot
org.apache.kafka.common.KafkaException: Socket server failed to bind to 114.115.20.100:9092: Cannot
77 0
|
缓存 Shell 网络安全
Github-推送代码报错“error:RPC failed;curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL,errno 10054”解决方案
Github-推送代码报错“error:RPC failed;curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL,errno 10054”解决方案
483 0
|
Java 关系型数据库 MySQL
14. 成功解决:ERROR:ssl_client_socket_impl.cc(992) handshake failed; returned -1, SSL error code 1, net_error -103
今天使用 Python 的 selenium 时,一直在报如下错误:[30616:22540:0328/093748.004:ERROR:ssl_client_socket_impl.cc(992)] handshake failed; returned -1, SSL error code 1, net_error -100
4253 0
|
网络安全
【IntelliJ IDEA】连接https报错问题: E230001: Server SSL certificate verification failed:
最近新安装了一个2018版本的idea,但是用idea去连接SVN的时候出现了这样的错误,在网上搜了很多,都没有用,最后找到这样的方式,把问题搞定,果断把解决方式记录下,以便帮助更多的人。
432 1
【IntelliJ IDEA】连接https报错问题: E230001: Server SSL certificate verification failed:
|
网络安全 Python Windows
ImportError: DLL load failed while importing _ssl: 找不到指定的模块。
找到Anaconda3\pkgs\python-3.8.12-h900ac77_2_cpython\DLLs下的_ssl.pyd文件,查阅在该环境上安装的python版本号,下载python寻找对应的_ssl.pyd覆盖到上述目录中,即可解决问题。
1036 0
|
前端开发 Python
解决报错:Websocket connection to‘ws://127.0.0.1:5000/socket.io/?EIO=4&transport=websocket’failed:Error
报错全文为:Websocket connection to‘ws://127.0.0.1:5000/socket.io/?EIO=4&transport=websocket’failed:Error during Websocket handshake:Unexpected response code:400。如下图所示。
解决报错:Websocket connection to‘ws://127.0.0.1:5000/socket.io/?EIO=4&transport=websocket’failed:Error
|
Java 应用服务中间件 测试技术
Tomcat异常——ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
Tomcat异常——ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
978 0
Tomcat异常——ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
|
网络安全
ssl.SSLError [SSL CERTIFICATE_VERIFY_FAILED] certificate verify failed
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
237 0
|
Shell 网络安全 开发工具
fatal: unable to access github.com schannel failed to receive handshake, SSL/TLS connection failed
fatal: unable to access github.com schannel failed to receive handshake, SSL/TLS connection failed
292 0