phpmailer发送邮件出现错误:stream_socket_enable_crypto(): SSL operation failed with code 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后默认开启验证
添加参数,去掉验证:
- $mail->SMTPOptions = array(
- 'ssl' => array(
- 'verify_peer' => false,
- 'verify_peer_name' => false,
- 'allow_self_signed' => true,
- )
- )
参考文档:
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
phpmailer发送邮件出现错误:stream_socket_enable_crypto(): SSL operation failed with code 1.的更多相关文章
- 使用PHPMailer 中的报错解决 "Connection failed. Error #2: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:"
PHPMailer项目地址:https://github.com/PHPMailer/PHPMailer 项目中用到PHPMailer,使用过程中报错:"Connection failed. ...
- file_get_contents(): SSL operation failed with code 1
出现file_get_contents(): SSL operation failed with code 1的错误 方法需要添加参数,如下: $stream_opts = [ "ssl&q ...
- 安装 composer SSL operation failed with code 1
gavin@webdev:~> curl -sS https://getcomposer.org/installer | php Downloading... Download failed: ...
- composer在update时提示file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO
在开发的时候,需要把依赖的服务更新到最新,然后 手动composer update一下,提示如下: failed) Update failed (The "e "https://a ...
- composer 安装提示 PHP Warning: readfile(): SSL operation failed with code 1
这是php设置openssl 没有指定cacert.pem (证书) 第一步:下载 cacert.pem 文件下载地址 https://curl.haxx.se/docs/caextract.html ...
- PHP函数file_get_contents()使用 https 协议时报错:SSL operation failed
场景: file_get_contents() 函数是用于将文件的内容读入到一个字符串中,是读取文件内容常用的函数之一. 但是有时在服务器上使用file_get_contents() 函数请求http ...
- failed to open stream: operation failed
# composer require oygza/aliyun-php-sdk-afs You are running composer with xdebug enabled. This has a ...
- linux下phpmailer发送邮件出现SMTP ERROR: Failed to connect to server: (0)错误
转自:https://www.cnblogs.com/raincowl/p/8875647.html //Create a new PHPMailer instance $mail = new PHP ...
- javamail发送邮件及错误解决方法javax.mail.AuthenticationFailedException: failed to connect, no password specified?
javamail发送邮件及错误解决方法javax.mail.AuthenticationFailedException: failed to connect, no password specifie ...
随机推荐
- elk +redis 环境搭建
这个是最新的elk+redis搭建日志分析平台,今年时间是2015年9月11日. Elk分别为 elasticsearch,logstash, kibana 官网为:https://www.elast ...
- iOS之富文本(二)
之前做项目时遇到一个问题: 使用UITextView显示一段电影的简介,由于字数比较多,所以字体设置的很小,行间距和段间距也很小,一大段文字挤在一起看起来很别扭,想要把行间距调大,结 ...
- 省选模拟赛 LYK loves string(string)
题目描述 LYK喜欢字符串,它认为一个长度为n的字符串一定会有n*(n+1)/2个子串,但是这些子串是不一定全部都不同的,也就是说,不相同的子串可能没有那么多个.LYK认为,两个字符串不同当且仅当它们 ...
- TCP ------ 抓包分析(seq ack)
总结: 1.ACK包可以和其他包合在一起,比如ACK包可以携带数据 2.可以接收多个数据包后,一次性给一个应答,不用每个数据包一一对应给应答 3.在通信过程中,通过接收到的包的ack值可以判断是否是上 ...
- Kubernetes Job配置
我们知道使用kubernetes的rc或者rs创建的pod,kubernetes会实时监控其健康状态,如果发现pod挂掉以后,会自动启动一个新的,让pod的数量始终保持在指定的replicas上.那么 ...
- jdk的keystore生成
使用jdk路径下的keytool.exe生成 生成证书: 导出证书,此时输入生成证书时设置的密码:
- libcurl移植到android
一.总体概览 C库:libcurl 3.7 目标平台:android 编译平台:ubuntu 12 编译工具:ndk r7 or later 二.已知方法 1. 官网上给了两种方法,第一种方法是使用a ...
- Linux下打包压缩war和解压war包 zip和jar
============jar================= 把当前目录下的所有文件打包成game.warjar -cvfM0 game.war ./ -c 创建war包-v 显示过程信息 ...
- 分块 (貌似能用LCT做,反正我现在还不会) BZOJ 2002
2002: [Hnoi2010]Bounce 弹飞绵羊 Time Limit: 10 Sec Memory Limit: 259 MBSubmit: 9844 Solved: 5070[Submi ...
- 【CodeForces】576 C. Points on Plane
[题目]C. Points on Plane [题意]给定坐标系中n个点的坐标(范围[0,10^6]),求一种 [ 连边形成链后总长度<=2.5*10^9 ] 的方案.n<=10^6. [ ...